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 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
32 // These are used for compiling out logging macros lower than a minimum severity.
33 #define RCUTILS_LOG_MIN_SEVERITY_DEBUG 0
34 #define RCUTILS_LOG_MIN_SEVERITY_INFO 1
35 #define RCUTILS_LOG_MIN_SEVERITY_WARN 2
36 #define RCUTILS_LOG_MIN_SEVERITY_ERROR 3
37 #define RCUTILS_LOG_MIN_SEVERITY_FATAL 4
38 #define RCUTILS_LOG_MIN_SEVERITY_NONE 5
39 
46 #ifndef RCUTILS_LOG_MIN_SEVERITY
47 #define RCUTILS_LOG_MIN_SEVERITY RCUTILS_LOG_MIN_SEVERITY_DEBUG
48 #endif
49 
50 // TODO(dhood): optimise severity check via notifyLoggerLevelsChanged concept or similar.
51 // The RCUTILS_LOG_COND_NAMED macro is surrounded by do { .. } while (0) to implement
52 // the standard C macro idiom to make the macro safe in all contexts; see
53 // http://c-faq.com/cpp/multistmt.html for more information.
66 #define RCUTILS_LOG_COND_NAMED(severity, condition_before, condition_after, name, ...) \
67  do { \
68  RCUTILS_LOGGING_AUTOINIT; \
69  static rcutils_log_location_t __rcutils_logging_location = {__func__, __FILE__, __LINE__}; \
70  if (rcutils_logging_logger_is_enabled_for(name, severity)) { \
71  condition_before \
72  rcutils_log(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
73  condition_after \
74  } \
75  } while (0)
76 
78 
83 #define RCUTILS_LOG_CONDITION_EMPTY
84 
89 
94 #define RCUTILS_LOG_CONDITION_ONCE_BEFORE \
95  { \
96  static int __rcutils_logging_once = 0; \
97  if (RCUTILS_UNLIKELY(0 == __rcutils_logging_once)) { \
98  __rcutils_logging_once = 1;
99 
103 #define RCUTILS_LOG_CONDITION_ONCE_AFTER } \
104 }
105 
110 
115 #define RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression) \
116  if (expression) {
117 
121 #define RCUTILS_LOG_CONDITION_EXPRESSION_AFTER }
122 
127 
132 typedef bool (* RclLogFilter)();
137 #define RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function) \
138  if ((*function)()) {
139 
143 #define RCUTILS_LOG_CONDITION_FUNCTION_AFTER }
144 
149 
154 #define RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE \
155  { \
156  static bool __rcutils_logging_first = true; \
157  if (RCUTILS_UNLIKELY(true == __rcutils_logging_first)) { \
158  __rcutils_logging_first = false; \
159  } else {
160 
164 #define RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER } \
165 }
166 
171 
176 #define RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) { \
177  static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS((rcutils_duration_value_t)duration); \
178  static rcutils_time_point_value_t __rcutils_logging_last_logged = 0; \
179  rcutils_time_point_value_t __rcutils_logging_now = 0; \
180  bool __rcutils_logging_condition = true; \
181  if (get_time_point_value(&__rcutils_logging_now) != RCUTILS_RET_OK) { \
182  rcutils_log( \
183  &__rcutils_logging_location, RCUTILS_LOG_SEVERITY_ERROR, "", \
184  "%s() at %s:%d getting current steady time failed\n", \
185  __func__, __FILE__, __LINE__); \
186  } else { \
187  __rcutils_logging_condition = __rcutils_logging_now >= __rcutils_logging_last_logged + __rcutils_logging_duration; \
188  } \
189  \
190  if (RCUTILS_LIKELY(__rcutils_logging_condition)) { \
191  __rcutils_logging_last_logged = __rcutils_logging_now;
192 
197 #define RCUTILS_LOG_CONDITION_THROTTLE_AFTER } \
198 }
199 
203 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_DEBUG)
205 // empty logging macros for severity DEBUG when being disabled at compile time
207 # define RCUTILS_LOG_DEBUG(format, ...)
208 # define RCUTILS_LOG_DEBUG_NAMED(name, format, ...)
210 # define RCUTILS_LOG_DEBUG_ONCE(format, ...)
212 # define RCUTILS_LOG_DEBUG_ONCE_NAMED(name, format, ...)
214 # define RCUTILS_LOG_DEBUG_EXPRESSION(expression, format, ...)
216 # define RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(expression, name, format, ...)
218 # define RCUTILS_LOG_DEBUG_FUNCTION(function, format, ...)
220 # define RCUTILS_LOG_DEBUG_FUNCTION_NAMED(function, name, format, ...)
222 # define RCUTILS_LOG_DEBUG_SKIPFIRST(format, ...)
224 # define RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED(name, format, ...)
226 # define RCUTILS_LOG_DEBUG_THROTTLE(get_time_point_value, duration, format, ...)
228 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE(get_time_point_value, duration, format, ...)
230 # define RCUTILS_LOG_DEBUG_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
232 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
234 
235 #else
236 
241 # define RCUTILS_LOG_DEBUG(...) \
242  RCUTILS_LOG_COND_NAMED( \
243  RCUTILS_LOG_SEVERITY_DEBUG, \
244  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
245  __VA_ARGS__)
246 
252 # define RCUTILS_LOG_DEBUG_NAMED(name, ...) \
253  RCUTILS_LOG_COND_NAMED( \
254  RCUTILS_LOG_SEVERITY_DEBUG, \
255  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
256  __VA_ARGS__)
257 
266 # define RCUTILS_LOG_DEBUG_ONCE(...) \
267  RCUTILS_LOG_COND_NAMED( \
268  RCUTILS_LOG_SEVERITY_DEBUG, \
269  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
270  __VA_ARGS__)
271 
281 # define RCUTILS_LOG_DEBUG_ONCE_NAMED(name, ...) \
282  RCUTILS_LOG_COND_NAMED( \
283  RCUTILS_LOG_SEVERITY_DEBUG, \
284  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
285  __VA_ARGS__)
286 
296 # define RCUTILS_LOG_DEBUG_EXPRESSION(expression, ...) \
297  RCUTILS_LOG_COND_NAMED( \
298  RCUTILS_LOG_SEVERITY_DEBUG, \
299  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
300  __VA_ARGS__)
301 
312 # define RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(expression, name, ...) \
313  RCUTILS_LOG_COND_NAMED( \
314  RCUTILS_LOG_SEVERITY_DEBUG, \
315  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
316  __VA_ARGS__)
317 
327 # define RCUTILS_LOG_DEBUG_FUNCTION(function, ...) \
328  RCUTILS_LOG_COND_NAMED( \
329  RCUTILS_LOG_SEVERITY_DEBUG, \
330  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
331  __VA_ARGS__)
332 
343 # define RCUTILS_LOG_DEBUG_FUNCTION_NAMED(function, name, ...) \
344  RCUTILS_LOG_COND_NAMED( \
345  RCUTILS_LOG_SEVERITY_DEBUG, \
346  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
347  __VA_ARGS__)
348 
357 # define RCUTILS_LOG_DEBUG_SKIPFIRST(...) \
358  RCUTILS_LOG_COND_NAMED( \
359  RCUTILS_LOG_SEVERITY_DEBUG, \
360  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
361  __VA_ARGS__)
362 
372 # define RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED(name, ...) \
373  RCUTILS_LOG_COND_NAMED( \
374  RCUTILS_LOG_SEVERITY_DEBUG, \
375  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
376  __VA_ARGS__)
377 
388 # define RCUTILS_LOG_DEBUG_THROTTLE(get_time_point_value, duration, ...) \
389  RCUTILS_LOG_COND_NAMED( \
390  RCUTILS_LOG_SEVERITY_DEBUG, \
391  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
392  __VA_ARGS__)
393 
405 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE(get_time_point_value, duration, ...) \
406  RCUTILS_LOG_COND_NAMED( \
407  RCUTILS_LOG_SEVERITY_DEBUG, \
408  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
409  __VA_ARGS__)
410 
422 # define RCUTILS_LOG_DEBUG_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
423  RCUTILS_LOG_COND_NAMED( \
424  RCUTILS_LOG_SEVERITY_DEBUG, \
425  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
426  __VA_ARGS__)
427 
440 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
441  RCUTILS_LOG_COND_NAMED( \
442  RCUTILS_LOG_SEVERITY_DEBUG, \
443  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
444  __VA_ARGS__)
445 #endif
446 
450 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_INFO)
452 // empty logging macros for severity INFO when being disabled at compile time
454 # define RCUTILS_LOG_INFO(format, ...)
455 # define RCUTILS_LOG_INFO_NAMED(name, format, ...)
457 # define RCUTILS_LOG_INFO_ONCE(format, ...)
459 # define RCUTILS_LOG_INFO_ONCE_NAMED(name, format, ...)
461 # define RCUTILS_LOG_INFO_EXPRESSION(expression, format, ...)
463 # define RCUTILS_LOG_INFO_EXPRESSION_NAMED(expression, name, format, ...)
465 # define RCUTILS_LOG_INFO_FUNCTION(function, format, ...)
467 # define RCUTILS_LOG_INFO_FUNCTION_NAMED(function, name, format, ...)
469 # define RCUTILS_LOG_INFO_SKIPFIRST(format, ...)
471 # define RCUTILS_LOG_INFO_SKIPFIRST_NAMED(name, format, ...)
473 # define RCUTILS_LOG_INFO_THROTTLE(get_time_point_value, duration, format, ...)
475 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE(get_time_point_value, duration, format, ...)
477 # define RCUTILS_LOG_INFO_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
479 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
481 
482 #else
483 
488 # define RCUTILS_LOG_INFO(...) \
489  RCUTILS_LOG_COND_NAMED( \
490  RCUTILS_LOG_SEVERITY_INFO, \
491  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
492  __VA_ARGS__)
493 
499 # define RCUTILS_LOG_INFO_NAMED(name, ...) \
500  RCUTILS_LOG_COND_NAMED( \
501  RCUTILS_LOG_SEVERITY_INFO, \
502  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
503  __VA_ARGS__)
504 
513 # define RCUTILS_LOG_INFO_ONCE(...) \
514  RCUTILS_LOG_COND_NAMED( \
515  RCUTILS_LOG_SEVERITY_INFO, \
516  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
517  __VA_ARGS__)
518 
528 # define RCUTILS_LOG_INFO_ONCE_NAMED(name, ...) \
529  RCUTILS_LOG_COND_NAMED( \
530  RCUTILS_LOG_SEVERITY_INFO, \
531  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
532  __VA_ARGS__)
533 
543 # define RCUTILS_LOG_INFO_EXPRESSION(expression, ...) \
544  RCUTILS_LOG_COND_NAMED( \
545  RCUTILS_LOG_SEVERITY_INFO, \
546  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
547  __VA_ARGS__)
548 
559 # define RCUTILS_LOG_INFO_EXPRESSION_NAMED(expression, name, ...) \
560  RCUTILS_LOG_COND_NAMED( \
561  RCUTILS_LOG_SEVERITY_INFO, \
562  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
563  __VA_ARGS__)
564 
574 # define RCUTILS_LOG_INFO_FUNCTION(function, ...) \
575  RCUTILS_LOG_COND_NAMED( \
576  RCUTILS_LOG_SEVERITY_INFO, \
577  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
578  __VA_ARGS__)
579 
590 # define RCUTILS_LOG_INFO_FUNCTION_NAMED(function, name, ...) \
591  RCUTILS_LOG_COND_NAMED( \
592  RCUTILS_LOG_SEVERITY_INFO, \
593  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
594  __VA_ARGS__)
595 
604 # define RCUTILS_LOG_INFO_SKIPFIRST(...) \
605  RCUTILS_LOG_COND_NAMED( \
606  RCUTILS_LOG_SEVERITY_INFO, \
607  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
608  __VA_ARGS__)
609 
619 # define RCUTILS_LOG_INFO_SKIPFIRST_NAMED(name, ...) \
620  RCUTILS_LOG_COND_NAMED( \
621  RCUTILS_LOG_SEVERITY_INFO, \
622  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
623  __VA_ARGS__)
624 
635 # define RCUTILS_LOG_INFO_THROTTLE(get_time_point_value, duration, ...) \
636  RCUTILS_LOG_COND_NAMED( \
637  RCUTILS_LOG_SEVERITY_INFO, \
638  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
639  __VA_ARGS__)
640 
652 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE(get_time_point_value, duration, ...) \
653  RCUTILS_LOG_COND_NAMED( \
654  RCUTILS_LOG_SEVERITY_INFO, \
655  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
656  __VA_ARGS__)
657 
669 # define RCUTILS_LOG_INFO_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
670  RCUTILS_LOG_COND_NAMED( \
671  RCUTILS_LOG_SEVERITY_INFO, \
672  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
673  __VA_ARGS__)
674 
687 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
688  RCUTILS_LOG_COND_NAMED( \
689  RCUTILS_LOG_SEVERITY_INFO, \
690  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
691  __VA_ARGS__)
692 #endif
693 
697 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_WARN)
699 // empty logging macros for severity WARN when being disabled at compile time
701 # define RCUTILS_LOG_WARN(format, ...)
702 # define RCUTILS_LOG_WARN_NAMED(name, format, ...)
704 # define RCUTILS_LOG_WARN_ONCE(format, ...)
706 # define RCUTILS_LOG_WARN_ONCE_NAMED(name, format, ...)
708 # define RCUTILS_LOG_WARN_EXPRESSION(expression, format, ...)
710 # define RCUTILS_LOG_WARN_EXPRESSION_NAMED(expression, name, format, ...)
712 # define RCUTILS_LOG_WARN_FUNCTION(function, format, ...)
714 # define RCUTILS_LOG_WARN_FUNCTION_NAMED(function, name, format, ...)
716 # define RCUTILS_LOG_WARN_SKIPFIRST(format, ...)
718 # define RCUTILS_LOG_WARN_SKIPFIRST_NAMED(name, format, ...)
720 # define RCUTILS_LOG_WARN_THROTTLE(get_time_point_value, duration, format, ...)
722 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE(get_time_point_value, duration, format, ...)
724 # define RCUTILS_LOG_WARN_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
726 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
728 
729 #else
730 
735 # define RCUTILS_LOG_WARN(...) \
736  RCUTILS_LOG_COND_NAMED( \
737  RCUTILS_LOG_SEVERITY_WARN, \
738  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
739  __VA_ARGS__)
740 
746 # define RCUTILS_LOG_WARN_NAMED(name, ...) \
747  RCUTILS_LOG_COND_NAMED( \
748  RCUTILS_LOG_SEVERITY_WARN, \
749  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
750  __VA_ARGS__)
751 
760 # define RCUTILS_LOG_WARN_ONCE(...) \
761  RCUTILS_LOG_COND_NAMED( \
762  RCUTILS_LOG_SEVERITY_WARN, \
763  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
764  __VA_ARGS__)
765 
775 # define RCUTILS_LOG_WARN_ONCE_NAMED(name, ...) \
776  RCUTILS_LOG_COND_NAMED( \
777  RCUTILS_LOG_SEVERITY_WARN, \
778  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
779  __VA_ARGS__)
780 
790 # define RCUTILS_LOG_WARN_EXPRESSION(expression, ...) \
791  RCUTILS_LOG_COND_NAMED( \
792  RCUTILS_LOG_SEVERITY_WARN, \
793  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
794  __VA_ARGS__)
795 
806 # define RCUTILS_LOG_WARN_EXPRESSION_NAMED(expression, name, ...) \
807  RCUTILS_LOG_COND_NAMED( \
808  RCUTILS_LOG_SEVERITY_WARN, \
809  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
810  __VA_ARGS__)
811 
821 # define RCUTILS_LOG_WARN_FUNCTION(function, ...) \
822  RCUTILS_LOG_COND_NAMED( \
823  RCUTILS_LOG_SEVERITY_WARN, \
824  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
825  __VA_ARGS__)
826 
837 # define RCUTILS_LOG_WARN_FUNCTION_NAMED(function, name, ...) \
838  RCUTILS_LOG_COND_NAMED( \
839  RCUTILS_LOG_SEVERITY_WARN, \
840  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
841  __VA_ARGS__)
842 
851 # define RCUTILS_LOG_WARN_SKIPFIRST(...) \
852  RCUTILS_LOG_COND_NAMED( \
853  RCUTILS_LOG_SEVERITY_WARN, \
854  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
855  __VA_ARGS__)
856 
866 # define RCUTILS_LOG_WARN_SKIPFIRST_NAMED(name, ...) \
867  RCUTILS_LOG_COND_NAMED( \
868  RCUTILS_LOG_SEVERITY_WARN, \
869  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
870  __VA_ARGS__)
871 
882 # define RCUTILS_LOG_WARN_THROTTLE(get_time_point_value, duration, ...) \
883  RCUTILS_LOG_COND_NAMED( \
884  RCUTILS_LOG_SEVERITY_WARN, \
885  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
886  __VA_ARGS__)
887 
899 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE(get_time_point_value, duration, ...) \
900  RCUTILS_LOG_COND_NAMED( \
901  RCUTILS_LOG_SEVERITY_WARN, \
902  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
903  __VA_ARGS__)
904 
916 # define RCUTILS_LOG_WARN_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
917  RCUTILS_LOG_COND_NAMED( \
918  RCUTILS_LOG_SEVERITY_WARN, \
919  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
920  __VA_ARGS__)
921 
934 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
935  RCUTILS_LOG_COND_NAMED( \
936  RCUTILS_LOG_SEVERITY_WARN, \
937  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
938  __VA_ARGS__)
939 #endif
940 
944 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_ERROR)
946 // empty logging macros for severity ERROR when being disabled at compile time
948 # define RCUTILS_LOG_ERROR(format, ...)
949 # define RCUTILS_LOG_ERROR_NAMED(name, format, ...)
951 # define RCUTILS_LOG_ERROR_ONCE(format, ...)
953 # define RCUTILS_LOG_ERROR_ONCE_NAMED(name, format, ...)
955 # define RCUTILS_LOG_ERROR_EXPRESSION(expression, format, ...)
957 # define RCUTILS_LOG_ERROR_EXPRESSION_NAMED(expression, name, format, ...)
959 # define RCUTILS_LOG_ERROR_FUNCTION(function, format, ...)
961 # define RCUTILS_LOG_ERROR_FUNCTION_NAMED(function, name, format, ...)
963 # define RCUTILS_LOG_ERROR_SKIPFIRST(format, ...)
965 # define RCUTILS_LOG_ERROR_SKIPFIRST_NAMED(name, format, ...)
967 # define RCUTILS_LOG_ERROR_THROTTLE(get_time_point_value, duration, format, ...)
969 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE(get_time_point_value, duration, format, ...)
971 # define RCUTILS_LOG_ERROR_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
973 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
975 
976 #else
977 
982 # define RCUTILS_LOG_ERROR(...) \
983  RCUTILS_LOG_COND_NAMED( \
984  RCUTILS_LOG_SEVERITY_ERROR, \
985  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
986  __VA_ARGS__)
987 
993 # define RCUTILS_LOG_ERROR_NAMED(name, ...) \
994  RCUTILS_LOG_COND_NAMED( \
995  RCUTILS_LOG_SEVERITY_ERROR, \
996  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
997  __VA_ARGS__)
998 
1007 # define RCUTILS_LOG_ERROR_ONCE(...) \
1008  RCUTILS_LOG_COND_NAMED( \
1009  RCUTILS_LOG_SEVERITY_ERROR, \
1010  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
1011  __VA_ARGS__)
1012 
1022 # define RCUTILS_LOG_ERROR_ONCE_NAMED(name, ...) \
1023  RCUTILS_LOG_COND_NAMED( \
1024  RCUTILS_LOG_SEVERITY_ERROR, \
1025  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
1026  __VA_ARGS__)
1027 
1037 # define RCUTILS_LOG_ERROR_EXPRESSION(expression, ...) \
1038  RCUTILS_LOG_COND_NAMED( \
1039  RCUTILS_LOG_SEVERITY_ERROR, \
1040  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
1041  __VA_ARGS__)
1042 
1053 # define RCUTILS_LOG_ERROR_EXPRESSION_NAMED(expression, name, ...) \
1054  RCUTILS_LOG_COND_NAMED( \
1055  RCUTILS_LOG_SEVERITY_ERROR, \
1056  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
1057  __VA_ARGS__)
1058 
1068 # define RCUTILS_LOG_ERROR_FUNCTION(function, ...) \
1069  RCUTILS_LOG_COND_NAMED( \
1070  RCUTILS_LOG_SEVERITY_ERROR, \
1071  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
1072  __VA_ARGS__)
1073 
1084 # define RCUTILS_LOG_ERROR_FUNCTION_NAMED(function, name, ...) \
1085  RCUTILS_LOG_COND_NAMED( \
1086  RCUTILS_LOG_SEVERITY_ERROR, \
1087  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
1088  __VA_ARGS__)
1089 
1098 # define RCUTILS_LOG_ERROR_SKIPFIRST(...) \
1099  RCUTILS_LOG_COND_NAMED( \
1100  RCUTILS_LOG_SEVERITY_ERROR, \
1101  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1102  __VA_ARGS__)
1103 
1113 # define RCUTILS_LOG_ERROR_SKIPFIRST_NAMED(name, ...) \
1114  RCUTILS_LOG_COND_NAMED( \
1115  RCUTILS_LOG_SEVERITY_ERROR, \
1116  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1117  __VA_ARGS__)
1118 
1129 # define RCUTILS_LOG_ERROR_THROTTLE(get_time_point_value, duration, ...) \
1130  RCUTILS_LOG_COND_NAMED( \
1131  RCUTILS_LOG_SEVERITY_ERROR, \
1132  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
1133  __VA_ARGS__)
1134 
1146 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE(get_time_point_value, duration, ...) \
1147  RCUTILS_LOG_COND_NAMED( \
1148  RCUTILS_LOG_SEVERITY_ERROR, \
1149  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1150  __VA_ARGS__)
1151 
1163 # define RCUTILS_LOG_ERROR_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
1164  RCUTILS_LOG_COND_NAMED( \
1165  RCUTILS_LOG_SEVERITY_ERROR, \
1166  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
1167  __VA_ARGS__)
1168 
1181 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
1182  RCUTILS_LOG_COND_NAMED( \
1183  RCUTILS_LOG_SEVERITY_ERROR, \
1184  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1185  __VA_ARGS__)
1186 #endif
1187 
1191 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_FATAL)
1193 // empty logging macros for severity FATAL when being disabled at compile time
1195 # define RCUTILS_LOG_FATAL(format, ...)
1196 # define RCUTILS_LOG_FATAL_NAMED(name, format, ...)
1198 # define RCUTILS_LOG_FATAL_ONCE(format, ...)
1200 # define RCUTILS_LOG_FATAL_ONCE_NAMED(name, format, ...)
1202 # define RCUTILS_LOG_FATAL_EXPRESSION(expression, format, ...)
1204 # define RCUTILS_LOG_FATAL_EXPRESSION_NAMED(expression, name, format, ...)
1206 # define RCUTILS_LOG_FATAL_FUNCTION(function, format, ...)
1208 # define RCUTILS_LOG_FATAL_FUNCTION_NAMED(function, name, format, ...)
1210 # define RCUTILS_LOG_FATAL_SKIPFIRST(format, ...)
1212 # define RCUTILS_LOG_FATAL_SKIPFIRST_NAMED(name, format, ...)
1214 # define RCUTILS_LOG_FATAL_THROTTLE(get_time_point_value, duration, format, ...)
1216 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE(get_time_point_value, duration, format, ...)
1218 # define RCUTILS_LOG_FATAL_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
1220 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, format, ...)
1222 
1223 #else
1224 
1229 # define RCUTILS_LOG_FATAL(...) \
1230  RCUTILS_LOG_COND_NAMED( \
1231  RCUTILS_LOG_SEVERITY_FATAL, \
1232  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
1233  __VA_ARGS__)
1234 
1240 # define RCUTILS_LOG_FATAL_NAMED(name, ...) \
1241  RCUTILS_LOG_COND_NAMED( \
1242  RCUTILS_LOG_SEVERITY_FATAL, \
1243  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
1244  __VA_ARGS__)
1245 
1254 # define RCUTILS_LOG_FATAL_ONCE(...) \
1255  RCUTILS_LOG_COND_NAMED( \
1256  RCUTILS_LOG_SEVERITY_FATAL, \
1257  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
1258  __VA_ARGS__)
1259 
1269 # define RCUTILS_LOG_FATAL_ONCE_NAMED(name, ...) \
1270  RCUTILS_LOG_COND_NAMED( \
1271  RCUTILS_LOG_SEVERITY_FATAL, \
1272  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
1273  __VA_ARGS__)
1274 
1284 # define RCUTILS_LOG_FATAL_EXPRESSION(expression, ...) \
1285  RCUTILS_LOG_COND_NAMED( \
1286  RCUTILS_LOG_SEVERITY_FATAL, \
1287  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
1288  __VA_ARGS__)
1289 
1300 # define RCUTILS_LOG_FATAL_EXPRESSION_NAMED(expression, name, ...) \
1301  RCUTILS_LOG_COND_NAMED( \
1302  RCUTILS_LOG_SEVERITY_FATAL, \
1303  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
1304  __VA_ARGS__)
1305 
1315 # define RCUTILS_LOG_FATAL_FUNCTION(function, ...) \
1316  RCUTILS_LOG_COND_NAMED( \
1317  RCUTILS_LOG_SEVERITY_FATAL, \
1318  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
1319  __VA_ARGS__)
1320 
1331 # define RCUTILS_LOG_FATAL_FUNCTION_NAMED(function, name, ...) \
1332  RCUTILS_LOG_COND_NAMED( \
1333  RCUTILS_LOG_SEVERITY_FATAL, \
1334  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
1335  __VA_ARGS__)
1336 
1345 # define RCUTILS_LOG_FATAL_SKIPFIRST(...) \
1346  RCUTILS_LOG_COND_NAMED( \
1347  RCUTILS_LOG_SEVERITY_FATAL, \
1348  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1349  __VA_ARGS__)
1350 
1360 # define RCUTILS_LOG_FATAL_SKIPFIRST_NAMED(name, ...) \
1361  RCUTILS_LOG_COND_NAMED( \
1362  RCUTILS_LOG_SEVERITY_FATAL, \
1363  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1364  __VA_ARGS__)
1365 
1376 # define RCUTILS_LOG_FATAL_THROTTLE(get_time_point_value, duration, ...) \
1377  RCUTILS_LOG_COND_NAMED( \
1378  RCUTILS_LOG_SEVERITY_FATAL, \
1379  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
1380  __VA_ARGS__)
1381 
1393 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE(get_time_point_value, duration, ...) \
1394  RCUTILS_LOG_COND_NAMED( \
1395  RCUTILS_LOG_SEVERITY_FATAL, \
1396  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1397  __VA_ARGS__)
1398 
1410 # define RCUTILS_LOG_FATAL_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
1411  RCUTILS_LOG_COND_NAMED( \
1412  RCUTILS_LOG_SEVERITY_FATAL, \
1413  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
1414  __VA_ARGS__)
1415 
1428 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED(get_time_point_value, duration, name, ...) \
1429  RCUTILS_LOG_COND_NAMED( \
1430  RCUTILS_LOG_SEVERITY_FATAL, \
1431  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1432  __VA_ARGS__)
1433 #endif
1434 
1436 #ifdef __cplusplus
1437 }
1438 #endif
1439 
1440 #endif // RCUTILS__LOGGING_MACROS_H_
RclLogFilter
bool(* RclLogFilter)()
Definition: logging_macros.h:132
logging.h