rcutils  master
C API providing common utilities and data structures.
logging_macros.h
Go to the documentation of this file.
1 // generated from rcutils/resource/logging_macros.h.em
2 
3 // Copyright 2017 Open Source Robotics Foundation, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
19 #ifndef RCUTILS__LOGGING_MACROS_H_
20 #define RCUTILS__LOGGING_MACROS_H_
21 
22 #include "rcutils/logging.h"
23 
24 #include <stdio.h>
25 #include <stdlib.h>
26 
27 #if __cplusplus
28 extern "C"
29 {
30 #endif
31 
37 #ifndef RCUTILS_LOG_MIN_SEVERITY
38 #define RCUTILS_LOG_MIN_SEVERITY RCUTILS_LOG_SEVERITY_DEBUG
39 #endif
40 
41 // Provide the compiler with branch prediction information
42 #ifndef WIN32
43 
47 # define RCUTILS_LIKELY(x) __builtin_expect((x), 1)
48 
52 # define RCUTILS_UNLIKELY(x) __builtin_expect((x), 0)
53 #else
54 
58 # define RCUTILS_LIKELY(x) (x)
59 
63 # define RCUTILS_UNLIKELY(x) (x)
64 #endif
65 
72 #define RCUTILS_LOGGING_AUTOINIT \
73  if (RCUTILS_UNLIKELY(!g_rcl_logging_initialized)) { \
74  rcl_logging_initialize(); \
75  }
76 
86 #define RCUTILS_LOG_COND_NAMED(severity, condition_before, condition_after, name, ...) \
87  { \
88  RCUTILS_LOGGING_AUTOINIT \
89  static rcl_log_location_t __rcutils_logging_location = {__func__, __FILE__, __LINE__}; \
90  condition_before \
91  if (severity >= g_rcl_logging_severity_threshold) { \
92  rcl_log(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
93  } \
94  condition_after \
95  }
96 
98 
103 #define RCUTILS_LOG_CONDITION_EMPTY
104 
109 
114 #define RCUTILS_LOG_CONDITION_ONCE_BEFORE \
115  { \
116  static int __rcutils_logging_once = 0; \
117  if (RCUTILS_UNLIKELY(0 == __rcutils_logging_once)) { \
118  __rcutils_logging_once = 1;
119 
123 #define RCUTILS_LOG_CONDITION_ONCE_AFTER } \
124  }
125 
130 
135 #define RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression) \
136  if (expression) {
137 
141 #define RCUTILS_LOG_CONDITION_EXPRESSION_AFTER }
142 
147 
152 typedef bool (* RclLogFilter)();
157 #define RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function) \
158  if ((*function)()) {
159 
163 #define RCUTILS_LOG_CONDITION_FUNCTION_AFTER }
164 
169 
174 #define RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE \
175  { \
176  static bool __rcutils_logging_first = true; \
177  if (RCUTILS_UNLIKELY(true == __rcutils_logging_first)) { \
178  __rcutils_logging_first = false; \
179  } else {
180 
184 #define RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER } \
185  }
186 
191 
196 #define RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) { \
197  static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS((rcutils_duration_value_t)duration); \
198  static rcutils_time_point_value_t __rcutils_logging_last_logged = 0; \
199  rcutils_time_point_value_t __rcutils_logging_now = 0; \
200  bool __rcutils_logging_condition = true; \
201  if (rcutils_steady_time_now(&__rcutils_logging_now) != RCUTILS_RET_OK) { \
202  rcl_log( \
203  &__rcutils_logging_location, RCUTILS_LOG_SEVERITY_ERROR, "", \
204  "%s() at %s:%d getting current steady time failed\n", \
205  __func__, __FILE__, __LINE__); \
206  } else { \
207  __rcutils_logging_condition = __rcutils_logging_now >= __rcutils_logging_last_logged + __rcutils_logging_duration; \
208  } \
209  \
210  if (RCUTILS_LIKELY(__rcutils_logging_condition)) { \
211  __rcutils_logging_last_logged = __rcutils_logging_now;
212 
217 #define RCUTILS_LOG_CONDITION_THROTTLE_AFTER } \
218  }
219 
223 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_SEVERITY_DEBUG)
225 // empty logging macros for severity DEBUG when being disabled at compile time
227 # define RCUTILS_LOG_DEBUG(format, ...)
228 # define RCUTILS_LOG_DEBUG_NAMED(name, format, ...)
230 # define RCUTILS_LOG_DEBUG_ONCE(format, ...)
232 # define RCUTILS_LOG_DEBUG_ONCE_NAMED(name, format, ...)
234 # define RCUTILS_LOG_DEBUG_EXPRESSION(expression, format, ...)
236 # define RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(expression, name, format, ...)
238 # define RCUTILS_LOG_DEBUG_FUNCTION(function, format, ...)
240 # define RCUTILS_LOG_DEBUG_FUNCTION_NAMED(function, name, format, ...)
242 # define RCUTILS_LOG_DEBUG_SKIPFIRST(format, ...)
244 # define RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED(name, format, ...)
246 # define RCUTILS_LOG_DEBUG_THROTTLE(time_source_type, duration, format, ...)
248 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
250 # define RCUTILS_LOG_DEBUG_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
252 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
254 
255 #else
256 
261 # define RCUTILS_LOG_DEBUG(...) \
262  RCUTILS_LOG_COND_NAMED( \
263  RCUTILS_LOG_SEVERITY_DEBUG, \
264  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, "", \
265  __VA_ARGS__)
266 
272 # define RCUTILS_LOG_DEBUG_NAMED(name, ...) \
273  RCUTILS_LOG_COND_NAMED( \
274  RCUTILS_LOG_SEVERITY_DEBUG, \
275  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
276  __VA_ARGS__)
277 
283 # define RCUTILS_LOG_DEBUG_ONCE(...) \
284  RCUTILS_LOG_COND_NAMED( \
285  RCUTILS_LOG_SEVERITY_DEBUG, \
286  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, "", \
287  __VA_ARGS__)
288 
295 # define RCUTILS_LOG_DEBUG_ONCE_NAMED(name, ...) \
296  RCUTILS_LOG_COND_NAMED( \
297  RCUTILS_LOG_SEVERITY_DEBUG, \
298  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
299  __VA_ARGS__)
300 
307 # define RCUTILS_LOG_DEBUG_EXPRESSION(expression, ...) \
308  RCUTILS_LOG_COND_NAMED( \
309  RCUTILS_LOG_SEVERITY_DEBUG, \
310  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, "", \
311  __VA_ARGS__)
312 
321 # define RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(expression, name, ...) \
322  RCUTILS_LOG_COND_NAMED( \
323  RCUTILS_LOG_SEVERITY_DEBUG, \
324  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
325  __VA_ARGS__)
326 
333 # define RCUTILS_LOG_DEBUG_FUNCTION(function, ...) \
334  RCUTILS_LOG_COND_NAMED( \
335  RCUTILS_LOG_SEVERITY_DEBUG, \
336  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, "", \
337  __VA_ARGS__)
338 
347 # define RCUTILS_LOG_DEBUG_FUNCTION_NAMED(function, name, ...) \
348  RCUTILS_LOG_COND_NAMED( \
349  RCUTILS_LOG_SEVERITY_DEBUG, \
350  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
351  __VA_ARGS__)
352 
358 # define RCUTILS_LOG_DEBUG_SKIPFIRST(...) \
359  RCUTILS_LOG_COND_NAMED( \
360  RCUTILS_LOG_SEVERITY_DEBUG, \
361  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
362  __VA_ARGS__)
363 
370 # define RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED(name, ...) \
371  RCUTILS_LOG_COND_NAMED( \
372  RCUTILS_LOG_SEVERITY_DEBUG, \
373  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
374  __VA_ARGS__)
375 
383 # define RCUTILS_LOG_DEBUG_THROTTLE(time_source_type, duration, ...) \
384  RCUTILS_LOG_COND_NAMED( \
385  RCUTILS_LOG_SEVERITY_DEBUG, \
386  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, "", \
387  __VA_ARGS__)
388 
397 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
398  RCUTILS_LOG_COND_NAMED( \
399  RCUTILS_LOG_SEVERITY_DEBUG, \
400  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
401  __VA_ARGS__)
402 
411 # define RCUTILS_LOG_DEBUG_THROTTLE_NAMED(time_source_type, duration, name, ...) \
412  RCUTILS_LOG_COND_NAMED( \
413  RCUTILS_LOG_SEVERITY_DEBUG, \
414  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
415  __VA_ARGS__)
416 
426 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
427  RCUTILS_LOG_COND_NAMED( \
428  RCUTILS_LOG_SEVERITY_DEBUG, \
429  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
430  __VA_ARGS__)
431 #endif
432 
436 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_SEVERITY_INFO)
438 // empty logging macros for severity INFO when being disabled at compile time
440 # define RCUTILS_LOG_INFO(format, ...)
441 # define RCUTILS_LOG_INFO_NAMED(name, format, ...)
443 # define RCUTILS_LOG_INFO_ONCE(format, ...)
445 # define RCUTILS_LOG_INFO_ONCE_NAMED(name, format, ...)
447 # define RCUTILS_LOG_INFO_EXPRESSION(expression, format, ...)
449 # define RCUTILS_LOG_INFO_EXPRESSION_NAMED(expression, name, format, ...)
451 # define RCUTILS_LOG_INFO_FUNCTION(function, format, ...)
453 # define RCUTILS_LOG_INFO_FUNCTION_NAMED(function, name, format, ...)
455 # define RCUTILS_LOG_INFO_SKIPFIRST(format, ...)
457 # define RCUTILS_LOG_INFO_SKIPFIRST_NAMED(name, format, ...)
459 # define RCUTILS_LOG_INFO_THROTTLE(time_source_type, duration, format, ...)
461 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
463 # define RCUTILS_LOG_INFO_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
465 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
467 
468 #else
469 
474 # define RCUTILS_LOG_INFO(...) \
475  RCUTILS_LOG_COND_NAMED( \
476  RCUTILS_LOG_SEVERITY_INFO, \
477  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, "", \
478  __VA_ARGS__)
479 
485 # define RCUTILS_LOG_INFO_NAMED(name, ...) \
486  RCUTILS_LOG_COND_NAMED( \
487  RCUTILS_LOG_SEVERITY_INFO, \
488  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
489  __VA_ARGS__)
490 
496 # define RCUTILS_LOG_INFO_ONCE(...) \
497  RCUTILS_LOG_COND_NAMED( \
498  RCUTILS_LOG_SEVERITY_INFO, \
499  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, "", \
500  __VA_ARGS__)
501 
508 # define RCUTILS_LOG_INFO_ONCE_NAMED(name, ...) \
509  RCUTILS_LOG_COND_NAMED( \
510  RCUTILS_LOG_SEVERITY_INFO, \
511  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
512  __VA_ARGS__)
513 
520 # define RCUTILS_LOG_INFO_EXPRESSION(expression, ...) \
521  RCUTILS_LOG_COND_NAMED( \
522  RCUTILS_LOG_SEVERITY_INFO, \
523  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, "", \
524  __VA_ARGS__)
525 
534 # define RCUTILS_LOG_INFO_EXPRESSION_NAMED(expression, name, ...) \
535  RCUTILS_LOG_COND_NAMED( \
536  RCUTILS_LOG_SEVERITY_INFO, \
537  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
538  __VA_ARGS__)
539 
546 # define RCUTILS_LOG_INFO_FUNCTION(function, ...) \
547  RCUTILS_LOG_COND_NAMED( \
548  RCUTILS_LOG_SEVERITY_INFO, \
549  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, "", \
550  __VA_ARGS__)
551 
560 # define RCUTILS_LOG_INFO_FUNCTION_NAMED(function, name, ...) \
561  RCUTILS_LOG_COND_NAMED( \
562  RCUTILS_LOG_SEVERITY_INFO, \
563  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
564  __VA_ARGS__)
565 
571 # define RCUTILS_LOG_INFO_SKIPFIRST(...) \
572  RCUTILS_LOG_COND_NAMED( \
573  RCUTILS_LOG_SEVERITY_INFO, \
574  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
575  __VA_ARGS__)
576 
583 # define RCUTILS_LOG_INFO_SKIPFIRST_NAMED(name, ...) \
584  RCUTILS_LOG_COND_NAMED( \
585  RCUTILS_LOG_SEVERITY_INFO, \
586  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
587  __VA_ARGS__)
588 
596 # define RCUTILS_LOG_INFO_THROTTLE(time_source_type, duration, ...) \
597  RCUTILS_LOG_COND_NAMED( \
598  RCUTILS_LOG_SEVERITY_INFO, \
599  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, "", \
600  __VA_ARGS__)
601 
610 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
611  RCUTILS_LOG_COND_NAMED( \
612  RCUTILS_LOG_SEVERITY_INFO, \
613  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
614  __VA_ARGS__)
615 
624 # define RCUTILS_LOG_INFO_THROTTLE_NAMED(time_source_type, duration, name, ...) \
625  RCUTILS_LOG_COND_NAMED( \
626  RCUTILS_LOG_SEVERITY_INFO, \
627  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
628  __VA_ARGS__)
629 
639 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
640  RCUTILS_LOG_COND_NAMED( \
641  RCUTILS_LOG_SEVERITY_INFO, \
642  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
643  __VA_ARGS__)
644 #endif
645 
649 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_SEVERITY_WARN)
651 // empty logging macros for severity WARN when being disabled at compile time
653 # define RCUTILS_LOG_WARN(format, ...)
654 # define RCUTILS_LOG_WARN_NAMED(name, format, ...)
656 # define RCUTILS_LOG_WARN_ONCE(format, ...)
658 # define RCUTILS_LOG_WARN_ONCE_NAMED(name, format, ...)
660 # define RCUTILS_LOG_WARN_EXPRESSION(expression, format, ...)
662 # define RCUTILS_LOG_WARN_EXPRESSION_NAMED(expression, name, format, ...)
664 # define RCUTILS_LOG_WARN_FUNCTION(function, format, ...)
666 # define RCUTILS_LOG_WARN_FUNCTION_NAMED(function, name, format, ...)
668 # define RCUTILS_LOG_WARN_SKIPFIRST(format, ...)
670 # define RCUTILS_LOG_WARN_SKIPFIRST_NAMED(name, format, ...)
672 # define RCUTILS_LOG_WARN_THROTTLE(time_source_type, duration, format, ...)
674 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
676 # define RCUTILS_LOG_WARN_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
678 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
680 
681 #else
682 
687 # define RCUTILS_LOG_WARN(...) \
688  RCUTILS_LOG_COND_NAMED( \
689  RCUTILS_LOG_SEVERITY_WARN, \
690  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, "", \
691  __VA_ARGS__)
692 
698 # define RCUTILS_LOG_WARN_NAMED(name, ...) \
699  RCUTILS_LOG_COND_NAMED( \
700  RCUTILS_LOG_SEVERITY_WARN, \
701  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
702  __VA_ARGS__)
703 
709 # define RCUTILS_LOG_WARN_ONCE(...) \
710  RCUTILS_LOG_COND_NAMED( \
711  RCUTILS_LOG_SEVERITY_WARN, \
712  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, "", \
713  __VA_ARGS__)
714 
721 # define RCUTILS_LOG_WARN_ONCE_NAMED(name, ...) \
722  RCUTILS_LOG_COND_NAMED( \
723  RCUTILS_LOG_SEVERITY_WARN, \
724  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
725  __VA_ARGS__)
726 
733 # define RCUTILS_LOG_WARN_EXPRESSION(expression, ...) \
734  RCUTILS_LOG_COND_NAMED( \
735  RCUTILS_LOG_SEVERITY_WARN, \
736  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, "", \
737  __VA_ARGS__)
738 
747 # define RCUTILS_LOG_WARN_EXPRESSION_NAMED(expression, name, ...) \
748  RCUTILS_LOG_COND_NAMED( \
749  RCUTILS_LOG_SEVERITY_WARN, \
750  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
751  __VA_ARGS__)
752 
759 # define RCUTILS_LOG_WARN_FUNCTION(function, ...) \
760  RCUTILS_LOG_COND_NAMED( \
761  RCUTILS_LOG_SEVERITY_WARN, \
762  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, "", \
763  __VA_ARGS__)
764 
773 # define RCUTILS_LOG_WARN_FUNCTION_NAMED(function, name, ...) \
774  RCUTILS_LOG_COND_NAMED( \
775  RCUTILS_LOG_SEVERITY_WARN, \
776  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
777  __VA_ARGS__)
778 
784 # define RCUTILS_LOG_WARN_SKIPFIRST(...) \
785  RCUTILS_LOG_COND_NAMED( \
786  RCUTILS_LOG_SEVERITY_WARN, \
787  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
788  __VA_ARGS__)
789 
796 # define RCUTILS_LOG_WARN_SKIPFIRST_NAMED(name, ...) \
797  RCUTILS_LOG_COND_NAMED( \
798  RCUTILS_LOG_SEVERITY_WARN, \
799  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
800  __VA_ARGS__)
801 
809 # define RCUTILS_LOG_WARN_THROTTLE(time_source_type, duration, ...) \
810  RCUTILS_LOG_COND_NAMED( \
811  RCUTILS_LOG_SEVERITY_WARN, \
812  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, "", \
813  __VA_ARGS__)
814 
823 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
824  RCUTILS_LOG_COND_NAMED( \
825  RCUTILS_LOG_SEVERITY_WARN, \
826  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
827  __VA_ARGS__)
828 
837 # define RCUTILS_LOG_WARN_THROTTLE_NAMED(time_source_type, duration, name, ...) \
838  RCUTILS_LOG_COND_NAMED( \
839  RCUTILS_LOG_SEVERITY_WARN, \
840  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
841  __VA_ARGS__)
842 
852 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
853  RCUTILS_LOG_COND_NAMED( \
854  RCUTILS_LOG_SEVERITY_WARN, \
855  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
856  __VA_ARGS__)
857 #endif
858 
862 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_SEVERITY_ERROR)
864 // empty logging macros for severity ERROR when being disabled at compile time
866 # define RCUTILS_LOG_ERROR(format, ...)
867 # define RCUTILS_LOG_ERROR_NAMED(name, format, ...)
869 # define RCUTILS_LOG_ERROR_ONCE(format, ...)
871 # define RCUTILS_LOG_ERROR_ONCE_NAMED(name, format, ...)
873 # define RCUTILS_LOG_ERROR_EXPRESSION(expression, format, ...)
875 # define RCUTILS_LOG_ERROR_EXPRESSION_NAMED(expression, name, format, ...)
877 # define RCUTILS_LOG_ERROR_FUNCTION(function, format, ...)
879 # define RCUTILS_LOG_ERROR_FUNCTION_NAMED(function, name, format, ...)
881 # define RCUTILS_LOG_ERROR_SKIPFIRST(format, ...)
883 # define RCUTILS_LOG_ERROR_SKIPFIRST_NAMED(name, format, ...)
885 # define RCUTILS_LOG_ERROR_THROTTLE(time_source_type, duration, format, ...)
887 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
889 # define RCUTILS_LOG_ERROR_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
891 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
893 
894 #else
895 
900 # define RCUTILS_LOG_ERROR(...) \
901  RCUTILS_LOG_COND_NAMED( \
902  RCUTILS_LOG_SEVERITY_ERROR, \
903  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, "", \
904  __VA_ARGS__)
905 
911 # define RCUTILS_LOG_ERROR_NAMED(name, ...) \
912  RCUTILS_LOG_COND_NAMED( \
913  RCUTILS_LOG_SEVERITY_ERROR, \
914  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
915  __VA_ARGS__)
916 
922 # define RCUTILS_LOG_ERROR_ONCE(...) \
923  RCUTILS_LOG_COND_NAMED( \
924  RCUTILS_LOG_SEVERITY_ERROR, \
925  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, "", \
926  __VA_ARGS__)
927 
934 # define RCUTILS_LOG_ERROR_ONCE_NAMED(name, ...) \
935  RCUTILS_LOG_COND_NAMED( \
936  RCUTILS_LOG_SEVERITY_ERROR, \
937  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
938  __VA_ARGS__)
939 
946 # define RCUTILS_LOG_ERROR_EXPRESSION(expression, ...) \
947  RCUTILS_LOG_COND_NAMED( \
948  RCUTILS_LOG_SEVERITY_ERROR, \
949  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, "", \
950  __VA_ARGS__)
951 
960 # define RCUTILS_LOG_ERROR_EXPRESSION_NAMED(expression, name, ...) \
961  RCUTILS_LOG_COND_NAMED( \
962  RCUTILS_LOG_SEVERITY_ERROR, \
963  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
964  __VA_ARGS__)
965 
972 # define RCUTILS_LOG_ERROR_FUNCTION(function, ...) \
973  RCUTILS_LOG_COND_NAMED( \
974  RCUTILS_LOG_SEVERITY_ERROR, \
975  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, "", \
976  __VA_ARGS__)
977 
986 # define RCUTILS_LOG_ERROR_FUNCTION_NAMED(function, name, ...) \
987  RCUTILS_LOG_COND_NAMED( \
988  RCUTILS_LOG_SEVERITY_ERROR, \
989  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
990  __VA_ARGS__)
991 
997 # define RCUTILS_LOG_ERROR_SKIPFIRST(...) \
998  RCUTILS_LOG_COND_NAMED( \
999  RCUTILS_LOG_SEVERITY_ERROR, \
1000  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
1001  __VA_ARGS__)
1002 
1009 # define RCUTILS_LOG_ERROR_SKIPFIRST_NAMED(name, ...) \
1010  RCUTILS_LOG_COND_NAMED( \
1011  RCUTILS_LOG_SEVERITY_ERROR, \
1012  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1013  __VA_ARGS__)
1014 
1022 # define RCUTILS_LOG_ERROR_THROTTLE(time_source_type, duration, ...) \
1023  RCUTILS_LOG_COND_NAMED( \
1024  RCUTILS_LOG_SEVERITY_ERROR, \
1025  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, "", \
1026  __VA_ARGS__)
1027 
1036 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
1037  RCUTILS_LOG_COND_NAMED( \
1038  RCUTILS_LOG_SEVERITY_ERROR, \
1039  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
1040  __VA_ARGS__)
1041 
1050 # define RCUTILS_LOG_ERROR_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1051  RCUTILS_LOG_COND_NAMED( \
1052  RCUTILS_LOG_SEVERITY_ERROR, \
1053  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
1054  __VA_ARGS__)
1055 
1065 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1066  RCUTILS_LOG_COND_NAMED( \
1067  RCUTILS_LOG_SEVERITY_ERROR, \
1068  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1069  __VA_ARGS__)
1070 #endif
1071 
1075 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_SEVERITY_FATAL)
1077 // empty logging macros for severity FATAL when being disabled at compile time
1079 # define RCUTILS_LOG_FATAL(format, ...)
1080 # define RCUTILS_LOG_FATAL_NAMED(name, format, ...)
1082 # define RCUTILS_LOG_FATAL_ONCE(format, ...)
1084 # define RCUTILS_LOG_FATAL_ONCE_NAMED(name, format, ...)
1086 # define RCUTILS_LOG_FATAL_EXPRESSION(expression, format, ...)
1088 # define RCUTILS_LOG_FATAL_EXPRESSION_NAMED(expression, name, format, ...)
1090 # define RCUTILS_LOG_FATAL_FUNCTION(function, format, ...)
1092 # define RCUTILS_LOG_FATAL_FUNCTION_NAMED(function, name, format, ...)
1094 # define RCUTILS_LOG_FATAL_SKIPFIRST(format, ...)
1096 # define RCUTILS_LOG_FATAL_SKIPFIRST_NAMED(name, format, ...)
1098 # define RCUTILS_LOG_FATAL_THROTTLE(time_source_type, duration, format, ...)
1100 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
1102 # define RCUTILS_LOG_FATAL_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
1104 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
1106 
1107 #else
1108 
1113 # define RCUTILS_LOG_FATAL(...) \
1114  RCUTILS_LOG_COND_NAMED( \
1115  RCUTILS_LOG_SEVERITY_FATAL, \
1116  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, "", \
1117  __VA_ARGS__)
1118 
1124 # define RCUTILS_LOG_FATAL_NAMED(name, ...) \
1125  RCUTILS_LOG_COND_NAMED( \
1126  RCUTILS_LOG_SEVERITY_FATAL, \
1127  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
1128  __VA_ARGS__)
1129 
1135 # define RCUTILS_LOG_FATAL_ONCE(...) \
1136  RCUTILS_LOG_COND_NAMED( \
1137  RCUTILS_LOG_SEVERITY_FATAL, \
1138  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, "", \
1139  __VA_ARGS__)
1140 
1147 # define RCUTILS_LOG_FATAL_ONCE_NAMED(name, ...) \
1148  RCUTILS_LOG_COND_NAMED( \
1149  RCUTILS_LOG_SEVERITY_FATAL, \
1150  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
1151  __VA_ARGS__)
1152 
1159 # define RCUTILS_LOG_FATAL_EXPRESSION(expression, ...) \
1160  RCUTILS_LOG_COND_NAMED( \
1161  RCUTILS_LOG_SEVERITY_FATAL, \
1162  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, "", \
1163  __VA_ARGS__)
1164 
1173 # define RCUTILS_LOG_FATAL_EXPRESSION_NAMED(expression, name, ...) \
1174  RCUTILS_LOG_COND_NAMED( \
1175  RCUTILS_LOG_SEVERITY_FATAL, \
1176  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
1177  __VA_ARGS__)
1178 
1185 # define RCUTILS_LOG_FATAL_FUNCTION(function, ...) \
1186  RCUTILS_LOG_COND_NAMED( \
1187  RCUTILS_LOG_SEVERITY_FATAL, \
1188  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, "", \
1189  __VA_ARGS__)
1190 
1199 # define RCUTILS_LOG_FATAL_FUNCTION_NAMED(function, name, ...) \
1200  RCUTILS_LOG_COND_NAMED( \
1201  RCUTILS_LOG_SEVERITY_FATAL, \
1202  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
1203  __VA_ARGS__)
1204 
1210 # define RCUTILS_LOG_FATAL_SKIPFIRST(...) \
1211  RCUTILS_LOG_COND_NAMED( \
1212  RCUTILS_LOG_SEVERITY_FATAL, \
1213  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
1214  __VA_ARGS__)
1215 
1222 # define RCUTILS_LOG_FATAL_SKIPFIRST_NAMED(name, ...) \
1223  RCUTILS_LOG_COND_NAMED( \
1224  RCUTILS_LOG_SEVERITY_FATAL, \
1225  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1226  __VA_ARGS__)
1227 
1235 # define RCUTILS_LOG_FATAL_THROTTLE(time_source_type, duration, ...) \
1236  RCUTILS_LOG_COND_NAMED( \
1237  RCUTILS_LOG_SEVERITY_FATAL, \
1238  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, "", \
1239  __VA_ARGS__)
1240 
1249 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
1250  RCUTILS_LOG_COND_NAMED( \
1251  RCUTILS_LOG_SEVERITY_FATAL, \
1252  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, "", \
1253  __VA_ARGS__)
1254 
1263 # define RCUTILS_LOG_FATAL_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1264  RCUTILS_LOG_COND_NAMED( \
1265  RCUTILS_LOG_SEVERITY_FATAL, \
1266  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
1267  __VA_ARGS__)
1268 
1278 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1279  RCUTILS_LOG_COND_NAMED( \
1280  RCUTILS_LOG_SEVERITY_FATAL, \
1281  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1282  __VA_ARGS__)
1283 #endif
1284 
1286 #if __cplusplus
1287 }
1288 #endif
1289 
1290 #endif // RCUTILS__LOGGING_MACROS_H_
bool(* RclLogFilter)()
Definition: logging_macros.h:152