log_utils.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2015, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 
37 #ifndef JSK_TOPIC_TOOLS_LOG_UTILS_H_
38 #define JSK_TOPIC_TOOLS_LOG_UTILS_H_
39 
40 #include <ros/ros.h>
41 #include <nodelet/nodelet.h>
42 
43 
44 namespace jsk_topic_tools
45 {
46 
52  bool warnNoRemap(const std::vector<std::string> names);
53 
54 
60  const std::string getFunctionName(const std::string &name);
61 
62 }
63 
64 #define JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX() \
65  ROS_WARN_ONCE("DEPRECATION WARNING: JSK_NODELET_XXX log macros are deprecated, and please use NODELET_XXX instead." \
66  " (See https://github.com/jsk-ros-pkg/jsk_common/issues/1461)");
67 #define JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX() \
68  ROS_WARN_ONCE("DEPRECATION WARNING: JSK_ROS_XXX log utils are deprecated, and please use ROS_XXX instead." \
69  " (See https://github.com/jsk-ros-pkg/jsk_common/issues/1461)");
70 
71 #define JSK_NODELET_DEBUG(str,...) \
72  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
73  NODELET_DEBUG("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
74 #define JSK_NODELET_INFO(str,...) \
75  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
76  NODELET_INFO("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
77 #define JSK_NODELET_WARN(str,...) \
78  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
79  NODELET_WARN("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
80 #define JSK_NODELET_ERROR(str,...) \
81  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
82  NODELET_ERROR("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
83 #define JSK_NODELET_FATAL(str,...) \
84  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
85  NODELET_FATAL("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
86 
87 #define JSK_NODELET_DEBUG_STREAM(...) \
88  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
89  NODELET_DEBUG_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
90 #define JSK_NODELET_INFO_STREAM(...) \
91  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
92  NODELET_INFO_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
93 #define JSK_NODELET_WARN_STREAM(...) \
94  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
95  NODELET_WARN_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
96 #define JSK_NODELET_ERROR_STREAM(...) \
97  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
98  NODELET_ERROR_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
99 #define JSK_NODELET_FATAL_STREAM(...) \
100  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
101  NODELET_FATAL_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
102 
103 #define JSK_NODELET_DEBUG_THROTTLE(rate, str, ...) \
104  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
105  NODELET_DEBUG_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
106 #define JSK_NODELET_INFO_THROTTLE(rate, str, ...) \
107  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
108  NODELET_INFO_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
109 #define JSK_NODELET_WARN_THROTTLE(rate, str, ...) \
110  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
111  NODELET_WARN_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
112 #define JSK_NODELET_ERROR_THROTTLE(rate, str, ...) \
113  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
114  NODELET_ERROR_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
115 #define JSK_NODELET_FATAL_THROTTLE(rate, str, ...) \
116  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
117  NODELET_FATAL_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
118 
119 #define JSK_NODELET_DEBUG_STREAM_THROTTLE(rate,...) \
120  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
121  NODELET_DEBUG_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
122 #define JSK_NODELET_INFO_STREAM_THROTTLE(rate,...) \
123  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
124  NODELET_INFO_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
125 #define JSK_NODELET_WARN_STREAM_THROTTLE(rate,...) \
126  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
127  NODELET_WARN_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
128 #define JSK_NODELET_ERROR_STREAM_THROTTLE(rate,...) \
129  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
130  NODELET_ERROR_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
131 #define JSK_NODELET_FATAL_STREAM_THROTTLE(rate,...) \
132  JSK_TOPIC_TOOLS_DEPRECATED_JSK_NODELET_XXX(); \
133  NODELET_FATAL_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
134 
135 #define JSK_ROS_DEBUG(str,...) \
136  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
137  ROS_DEBUG("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
138 #define JSK_ROS_INFO(str,...) \
139  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
140  ROS_INFO("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
141 #define JSK_ROS_WARN(str,...) \
142  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
143  ROS_WARN("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
144 #define JSK_ROS_ERROR(str,...) \
145  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
146  ROS_ERROR("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
147 #define JSK_ROS_FATAL(str,...) \
148  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
149  ROS_FATAL("[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
150 
151 #define JSK_ROS_DEBUG_STREAM(...) \
152  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
153  ROS_DEBUG_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
154 #define JSK_ROS_INFO_STREAM(...) \
155  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
156  ROS_INFO_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
157 #define JSK_ROS_WARN_STREAM(...) \
158  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
159  ROS_WARN_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
160 #define JSK_ROS_ERROR_STREAM(...) \
161  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
162  ROS_ERROR_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
163 #define JSK_ROS_FATAL_STREAM(...) \
164  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
165  ROS_FATAL_STREAM("[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
166 
167 #define JSK_ROS_DEBUG_THROTTLE(rate, str, ...) \
168  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
169  ROS_DEBUG_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
170 #define JSK_ROS_INFO_THROTTLE(rate, str, ...) \
171  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
172  ROS_INFO_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
173 #define JSK_ROS_WARN_THROTTLE(rate, str, ...) \
174  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
175  ROS_WARN_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
176 #define JSK_ROS_ERROR_THROTTLE(rate, str, ...) \
177  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
178  ROS_ERROR_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
179 #define JSK_ROS_FATAL_THROTTLE(rate, str, ...) \
180  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
181  ROS_FATAL_THROTTLE(rate, "[%s] " str, jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str(), ##__VA_ARGS__)
182 
183 #define JSK_ROS_DEBUG_STREAM_THROTTLE(rate,...) \
184  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
185  ROS_DEBUG_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
186 #define JSK_ROS_INFO_STREAM_THROTTLE(rate,...) \
187  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
188  ROS_INFO_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
189 #define JSK_ROS_WARN_STREAM_THROTTLE(rate,...) \
190  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
191  ROS_WARN_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
192 #define JSK_ROS_ERROR_STREAM_THROTTLE(rate,...) \
193  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
194  ROS_ERROR_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
195 #define JSK_ROS_FATAL_STREAM_THROTTLE(rate,...) \
196  JSK_TOPIC_TOOLS_DEPRECATED_JSK_ROS_XXX(); \
197  ROS_FATAL_STREAM_THROTTLE(rate, "[" << jsk_topic_tools::getFunctionName(__PRETTY_FUNCTION__).c_str() << "] " << __VA_ARGS__)
198 
199 #endif
const std::string getFunctionName(const std::string &name)
Get only function name from PRETTY_FUNCTION
Definition: log_utils.cpp:62
bool warnNoRemap(const std::vector< std::string > names)
warn if there are expected remappings.
Definition: log_utils.cpp:44


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:19