|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
19 # define __YFUNCTION__ __PRETTY_FUNCTION__
20 #elif defined(_MSC_VER)
21 # define __YFUNCTION__ __FUNCSIG__
22 #elif (__cplusplus <= 199711)
23 # define __YFUNCTION__ __func__
25 # define __YFUNCTION__ "(unknown function)"
33 # define YARP_ATTRIBUTE_FORMAT(style, fmt, args) __attribute__((format(printf, (fmt), (args))))
35 # define YARP_ATTRIBUTE_FORMAT(style, fmt, args)
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
50 #endif // DOXYGEN_SHOULD_SKIP_THIS
58 const unsigned int line,
65 const unsigned int line,
67 const double externaltime,
83 LogTypeReserved = 0xFF
103 const
unsigned int line,
108 const
char* comp_name);
110 #ifndef YARP_NO_DEPRECATED // Since YARP 3.4
113 #endif // YARP_NO_DEPRECATED
115 static void setMinimumPrintLevel(
LogType level);
116 static LogType minimumPrintLevel();
117 static LogType defaultMinimumPrintLevel();
119 static void setMinimumForwardLevel(
LogType level);
120 static LogType minimumForwardLevel();
121 static LogType defaultMinimumForwardLevel();
132 #ifndef DOXYGEN_SHOULD_SKIP_THIS
133 static void nolog(
const char* msg, ...) {}
136 template <
typename T>
142 static NoLog nolog() {
return NoLog(); }
153 const unsigned int line,
158 const LogComponent& comp_name);
161 static const LogComponent& defaultLogComponent();
164 static const LogComponent& logInternalComponent();
165 #endif // DOXYGEN_SHOULD_SKIP_THIS
174 #define YARP_ONCE_CALLBACK \
176 static std::atomic_flag flag = ATOMIC_FLAG_INIT; \
177 return !flag.test_and_set(); \
180 #define YARP_THREADONCE_CALLBACK \
182 thread_local std::atomic_flag flag = ATOMIC_FLAG_INIT; \
183 return !flag.test_and_set(); \
186 #define YARP_THROTTLE_CALLBACK(period) \
188 static double last = -period; \
189 static std::mutex mutex; \
190 std::lock_guard<std::mutex> lock(mutex); \
191 double now = yarp::os::SystemClock::nowSystem(); \
192 if (now >= last + period) { \
199 #define YARP_THREADTHROTTLE_CALLBACK(period) \
201 thread_local double last = -period; \
202 double now = yarp::os::SystemClock::nowSystem(); \
203 if (now >= last + period) { \
213 # define yTrace(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__).trace(__VA_ARGS__)
214 # define yTraceOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK).trace(__VA_ARGS__)
215 # define yTraceThreadOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK).trace(__VA_ARGS__)
216 # define yTraceThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period)).trace(__VA_ARGS__)
217 # define yTraceThreadThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period)).trace(__VA_ARGS__)
218 # define yTraceExternalTime(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime).trace(__VA_ARGS__)
219 # define yTraceExternalTimeOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK).trace(__VA_ARGS__)
220 # define yTraceExternalTimeThreadOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK).trace(__VA_ARGS__)
221 # define yTraceExternalTimeThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period)).trace(__VA_ARGS__)
222 # define yTraceExternalTimeThreadThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period)).trace(__VA_ARGS__)
224 # define yTrace(...) yarp::os::Log::nolog(__VA_ARGS__)
225 # define yTraceOnce(...) yarp::os::Log::nolog(__VA_ARGS__)
226 # define yTraceThreadOnce(...) yarp::os::Log::nolog(__VA_ARGS__)
227 # define yTraceThrottle(period, ...) yarp::os::Log::nolog(__VA_ARGS__)
228 # define yTraceThreadThrottle(period, ...) yarp::os::Log::nolog(__VA_ARGS__)
229 # define yTraceExternalTime(externaltime, ...) yarp::os::Log::nolog(__VA_ARGS__)
230 # define yTraceExternalTimeOnce(externaltime, ...) yarp::os::Log::nolog(__VA_ARGS__)
231 # define yTraceExternalTimeThreadOnce(externaltime, ...) yarp::os::Log::nolog(__VA_ARGS__)
232 # define yTraceExternalTimeThrottle(externaltime, period, ...) yarp::os::Log::nolog(__VA_ARGS__)
233 # define yTraceExternalTimeThreadThrottle(externaltime, period, ...) yarp::os::Log::nolog(__VA_ARGS__)
236 #ifndef YARP_NO_DEBUG_OUTPUT
237 # define yDebug(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__).debug(__VA_ARGS__)
238 # define yDebugOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK).debug(__VA_ARGS__)
239 # define yDebugThreadOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK).debug(__VA_ARGS__)
240 # define yDebugThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period)).debug(__VA_ARGS__)
241 # define yDebugThreadThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period)).debug(__VA_ARGS__)
242 # define yDebugExternalTime(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime).debug(__VA_ARGS__)
243 # define yDebugExternalTimeOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK).debug(__VA_ARGS__)
244 # define yDebugExternalTimeThreadOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK).debug(__VA_ARGS__)
245 # define yDebugExternalTimeThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period)).debug(__VA_ARGS__)
246 # define yDebugExternalTimeThreadThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period)).debug(__VA_ARGS__)
248 # define yDebug(...) yarp::os::Log::nolog(__VA_ARGS__)
249 # define yDebugOnce(...) yarp::os::Log::nolog(__VA_ARGS__)
250 # define yDebugThreadOnce(...) yarp::os::Log::nolog(__VA_ARGS__)
251 # define yDebugThrottle(period, ...) yarp::os::Log::nolog(__VA_ARGS__)
252 # define yDebugThreadThrottle(period, ...) yarp::os::Log::nolog(__VA_ARGS__)
253 # define yDebugExternalTime(externaltime, ...) yarp::os::Log::nolog(__VA_ARGS__)
254 # define yDebugExternalTimeOnce(externaltime, ...) yarp::os::Log::nolog(__VA_ARGS__)
255 # define yDebugExternalTimeThreadOnce(externaltime, ...) yarp::os::Log::nolog(__VA_ARGS__)
256 # define yDebugExternalTimeThrottle(externaltime, period, ...) yarp::os::Log::nolog(__VA_ARGS__)
257 # define yDebugExternalTimeThreadThrottle(externaltime, period, ...) yarp::os::Log::nolog(__VA_ARGS__)
260 #define yInfo(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__).info(__VA_ARGS__)
261 #define yInfoOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK).info(__VA_ARGS__)
262 #define yInfoThreadOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK).info(__VA_ARGS__)
263 #define yInfoThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period)).info(__VA_ARGS__)
264 #define yInfoThreadThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period)).info(__VA_ARGS__)
265 #define yInfoExternalTime(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime).info(__VA_ARGS__)
266 #define yInfoExternalTimeOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK).info(__VA_ARGS__)
267 #define yInfoExternalTimeThreadOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK).info(__VA_ARGS__)
268 #define yInfoExternalTimeThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period)).info(__VA_ARGS__)
269 #define yInfoExternalTimeThreadThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period)).info(__VA_ARGS__)
271 #define yWarning(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__).warning(__VA_ARGS__)
272 #define yWarningOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK).warning(__VA_ARGS__)
273 #define yWarningThreadOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK).warning(__VA_ARGS__)
274 #define yWarningThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period)).warning(__VA_ARGS__)
275 #define yWarningThreadThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period)).warning(__VA_ARGS__)
276 #define yWarningExternalTime(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime).warning(__VA_ARGS__)
277 #define yWarningExternalTimeOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK).warning(__VA_ARGS__)
278 #define yWarningExternalTimeThreadOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK).warning(__VA_ARGS__)
279 #define yWarningExternalTimeThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period)).warning(__VA_ARGS__)
280 #define yWarningExternalTimeThreadThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period)).warning(__VA_ARGS__)
282 #define yError(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__).error(__VA_ARGS__)
283 #define yErrorOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK).error(__VA_ARGS__)
284 #define yErrorThreadOnce(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK).error(__VA_ARGS__)
285 #define yErrorThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period)).error(__VA_ARGS__)
286 #define yErrorThreadThrottle(period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period)).error(__VA_ARGS__)
287 #define yErrorExternalTime(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime).error(__VA_ARGS__)
288 #define yErrorExternalTimeOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK).error(__VA_ARGS__)
289 #define yErrorExternalTimeThreadOnce(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK).error(__VA_ARGS__)
290 #define yErrorExternalTimeThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period)).error(__VA_ARGS__)
291 #define yErrorExternalTimeThreadThrottle(externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period)).error(__VA_ARGS__)
293 #define yFatal(...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__).fatal(__VA_ARGS__)
294 #define yFatalExternalTime(externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime).fatal(__VA_ARGS__)
297 # define yAssert(x) \
299 yFatal("Assertion failure at %s:%d (%s)", __FILE__, __LINE__, #x); \
301 # define yAssertExternalTime(externaltime, x) \
303 yFatalExternalTime(externaltime, "Assertion failure at %s:%d (%s)", __FILE__, __LINE__, #x); \
307 # define yAssertExternalTime(externaltime, x) { YARP_UNUSED(externaltime); }
310 #define YARP_FIXME_NOTIMPLEMENTED(what) yWarning("FIXME: %s not yet implemented", what);
319 #endif // YARP_OS_LOG_H
std::ostream & operator<<(std::ostream &os, StrStream &sstr)
void yarp_print_trace(FILE *out, const char *file, unsigned int line)
Low level function for printing a stack trace, if implemented (ACE or gcc/Linux).
#define YARP_ATTRIBUTE_FORMAT(style, fmt, args)
#define YARP_DEPRECATED_MSG(MSG)
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
The main, catch-all namespace for YARP.
void(*)(yarp::os::Log::LogType type, const char *msg, const char *file, const unsigned int line, const char *func, double systemtime, double networktime, double externaltime, const char *comp_name) LogCallback