|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
9 #ifndef YARP_OS_LOGCOMPONENT_H
10 #define YARP_OS_LOGCOMPONENT_H
42 constexpr const
char* name()
const {
return m_name; }
43 constexpr
operator bool()
const {
return m_name !=
nullptr; }
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 #ifndef YARP_NO_DEPRECATED // Since YARP 3.4
50 void setMinimumPrintLevel(LogType minimumPrintLevel);
51 void setMinimumForwardLevel(LogType minimumForwardLevel);
52 #endif // YARP_NO_DEPRECATED
55 const char* m_name {
nullptr };
73 #endif // DOXYGEN_SHOULD_SKIP_THIS
77 #define YARP_DECLARE_LOG_COMPONENT(name) \
78 extern const yarp::os::LogComponent& name();
80 #define YARP_LOG_COMPONENT(name, ...) \
81 const yarp::os::LogComponent& name() \
83 static const yarp::os::LogComponent component(__VA_ARGS__); \
88 # define yCTrace(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, nullptr, component()).trace(__VA_ARGS__)
89 # define yCTraceOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK, component()).trace(__VA_ARGS__)
90 # define yCTraceThreadOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK, component()).trace(__VA_ARGS__)
91 # define yCTraceThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period), component()).trace(__VA_ARGS__)
92 # define yCTraceThreadThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period), component()).trace(__VA_ARGS__)
93 # define yCTraceExternalTime(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, nullptr, component()).trace(__VA_ARGS__)
94 # define yCTraceExternalTimeOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK, component()).trace(__VA_ARGS__)
95 # define yCTraceExternalTimeThreadOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK, component()).trace(__VA_ARGS__)
96 # define yCTraceExternalTimeThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period), component()).trace(__VA_ARGS__)
97 # define yCTraceExternalTimeThreadThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period), component()).trace(__VA_ARGS__)
99 # define yCTrace(component, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
100 # define yCTraceOnce(component, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
101 # define yCTraceThreadOnce(component, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
102 # define yCTraceThrottle(component, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
103 # define yCTraceThreadThrottle(component, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
104 # define yCTraceExternalTime(component, externaltime, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
105 # define yCTraceExternalTimeOnce(component, externaltime, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
106 # define yCTraceExternalTimeThreadOnce(component, externaltime, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
107 # define yCTraceExternalTimeThrottle(component, externaltime, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
108 # define yCTraceExternalTimeThreadThrottle(component, externaltime, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
111 #ifndef YARP_NO_DEBUG_OUTPUT
112 # define yCDebug(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, nullptr, component()).debug(__VA_ARGS__)
113 # define yCDebugOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK, component()).debug(__VA_ARGS__)
114 # define yCDebugThreadOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK, component()).debug(__VA_ARGS__)
115 # define yCDebugThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period), component()).debug(__VA_ARGS__)
116 # define yCDebugThreadThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period), component()).debug(__VA_ARGS__)
117 # define yCDebugExternalTime(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, nullptr, component()).debug(__VA_ARGS__)
118 # define yCDebugExternalTimeOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK, component()).debug(__VA_ARGS__)
119 # define yCDebugExternalTimeThreadOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK, component()).debug(__VA_ARGS__)
120 # define yCDebugExternalTimeThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period), component()).debug(__VA_ARGS__)
121 # define yCDebugExternalTimeThreadThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period), component()).debug(__VA_ARGS__)
123 # define yCDebug(component, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
124 # define yCDebugOnce(component, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
125 # define yCDebugThreadOnce(component, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
126 # define yCDebugThrottle(component, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
127 # define yCDebugThreadThrottle(component, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
128 # define yCDebugExternalTime(component, externaltime, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
129 # define yCDebugExternalTimeOnce(component, externaltime, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
130 # define yCDebugExternalTimeThreadOnce(component, externaltime, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
131 # define yCDebugExternalTimeThrottle(component, externaltime, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
132 # define yCDebugExternalTimeThreadThrottle(component, externaltime, period, ...) YARP_UNUSED(component); yarp::os::Log::nolog(__VA_ARGS__)
135 #define yCInfo(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, nullptr, component()).info(__VA_ARGS__)
136 #define yCInfoOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK, component()).info(__VA_ARGS__)
137 #define yCInfoThreadOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK, component()).info(__VA_ARGS__)
138 #define yCInfoThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period), component()).info(__VA_ARGS__)
139 #define yCInfoThreadThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period), component()).info(__VA_ARGS__)
140 #define yCInfoExternalTime(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, nullptr, component()).info(__VA_ARGS__)
141 #define yCInfoExternalTimeOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK, component()).info(__VA_ARGS__)
142 #define yCInfoExternalTimeThreadOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK, component()).info(__VA_ARGS__)
143 #define yCInfoExternalTimeThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period), component()).info(__VA_ARGS__)
144 #define yCInfoExternalTimeThreadThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period), component()).info(__VA_ARGS__)
146 #define yCWarning(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, nullptr, component()).warning(__VA_ARGS__)
147 #define yCWarningOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK, component()).warning(__VA_ARGS__)
148 #define yCWarningThreadOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK, component()).warning(__VA_ARGS__)
149 #define yCWarningThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period), component()).warning(__VA_ARGS__)
150 #define yCWarningThreadThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period), component()).warning(__VA_ARGS__)
151 #define yCWarningExternalTime(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, nullptr, component()).warning(__VA_ARGS__)
152 #define yCWarningExternalTimeOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK, component()).warning(__VA_ARGS__)
153 #define yCWarningExternalTimeThreadOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK, component()).warning(__VA_ARGS__)
154 #define yCWarningExternalTimeThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period), component()).warning(__VA_ARGS__)
155 #define yCWarningExternalTimeThreadThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period), component()).warning(__VA_ARGS__)
157 #define yCError(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, nullptr, component()).error(__VA_ARGS__)
158 #define yCErrorOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_ONCE_CALLBACK, component()).error(__VA_ARGS__)
159 #define yCErrorThreadOnce(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADONCE_CALLBACK, component()).error(__VA_ARGS__)
160 #define yCErrorThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THROTTLE_CALLBACK(period), component()).error(__VA_ARGS__)
161 #define yCErrorThreadThrottle(component, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, YARP_THREADTHROTTLE_CALLBACK(period), component()).error(__VA_ARGS__)
162 #define yCErrorExternalTime(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, nullptr, component()).error(__VA_ARGS__)
163 #define yCErrorExternalTimeOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_ONCE_CALLBACK, component()).error(__VA_ARGS__)
164 #define yCErrorExternalTimeThreadOnce(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADONCE_CALLBACK, component()).error(__VA_ARGS__)
165 #define yCErrorExternalTimeThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THROTTLE_CALLBACK(period), component()).error(__VA_ARGS__)
166 #define yCErrorExternalTimeThreadThrottle(component, externaltime, period, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, YARP_THREADTHROTTLE_CALLBACK(period), component()).error(__VA_ARGS__)
168 #define yCFatal(component, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, nullptr, component()).fatal(__VA_ARGS__)
169 #define yCFatalExternalTime(component, externaltime, ...) yarp::os::Log(__FILE__, __LINE__, __YFUNCTION__, externaltime, nullptr, component()).fatal(__VA_ARGS__)
172 # define yCAssert(component, x) \
174 yCFatal(component, "Assertion failure at %s:%d (%s)", __FILE__, __LINE__, #x); \
176 # define yCAssertExternalTime(component, externaltime, x) \
178 yCFatalExternalTime(component, externaltime, "Assertion failure at %s:%d (%s)", __FILE__, __LINE__, #x); \
181 # define yCAssert(component, x) { YARP_UNUSED(component); }
182 # define yCAssertExternalTime(component, externaltime, x) { YARP_UNUSED(component); YARP_UNUSED(externaltime); }
189 #endif // YARP_OS_LOGCOMPONENT_H
yarp::os::Log::LogCallback LogCallback
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
static LogCallback forwardCallback()
Get current forward callback (or nullptr if forwarding is not enabled)
LogComponent(const LogComponent &)=delete
static LogType minimumPrintLevel()
Get current minimum print level.
LogComponent(LogComponent &&) noexcept=delete
yarp::os::Log::LogCallback LogCallback
static LogType minimumForwardLevel()
Get current minimum forward level (or LogTypeReserved if forwarding is not enabled)
The main, catch-all namespace for YARP.
static LogCallback printCallback()
Get current print callback.
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