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 
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.
63 #define RCUTILS_LOG_COND_NAMED(severity, condition_before, condition_after, name, ...) \
64  { \
65  RCUTILS_LOGGING_AUTOINIT \
66  static rcutils_log_location_t __rcutils_logging_location = {__func__, __FILE__, __LINE__}; \
67  if (rcutils_logging_logger_is_enabled_for(name, severity)) { \
68  condition_before \
69  rcutils_log(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
70  condition_after \
71  } \
72  }
73 
75 
80 #define RCUTILS_LOG_CONDITION_EMPTY
81 
86 
91 #define RCUTILS_LOG_CONDITION_ONCE_BEFORE \
92  { \
93  static int __rcutils_logging_once = 0; \
94  if (RCUTILS_UNLIKELY(0 == __rcutils_logging_once)) { \
95  __rcutils_logging_once = 1;
96 
100 #define RCUTILS_LOG_CONDITION_ONCE_AFTER } \
101  }
102 
107 
112 #define RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression) \
113  if (expression) {
114 
118 #define RCUTILS_LOG_CONDITION_EXPRESSION_AFTER }
119 
124 
129 typedef bool (* RclLogFilter)();
134 #define RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function) \
135  if ((*function)()) {
136 
140 #define RCUTILS_LOG_CONDITION_FUNCTION_AFTER }
141 
146 
151 #define RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE \
152  { \
153  static bool __rcutils_logging_first = true; \
154  if (RCUTILS_UNLIKELY(true == __rcutils_logging_first)) { \
155  __rcutils_logging_first = false; \
156  } else {
157 
161 #define RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER } \
162  }
163 
168 
173 #define RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) { \
174  static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS((rcutils_duration_value_t)duration); \
175  static rcutils_time_point_value_t __rcutils_logging_last_logged = 0; \
176  rcutils_time_point_value_t __rcutils_logging_now = 0; \
177  bool __rcutils_logging_condition = true; \
178  if (rcutils_steady_time_now(&__rcutils_logging_now) != RCUTILS_RET_OK) { \
179  rcutils_log( \
180  &__rcutils_logging_location, RCUTILS_LOG_SEVERITY_ERROR, "", \
181  "%s() at %s:%d getting current steady time failed\n", \
182  __func__, __FILE__, __LINE__); \
183  } else { \
184  __rcutils_logging_condition = __rcutils_logging_now >= __rcutils_logging_last_logged + __rcutils_logging_duration; \
185  } \
186  \
187  if (RCUTILS_LIKELY(__rcutils_logging_condition)) { \
188  __rcutils_logging_last_logged = __rcutils_logging_now;
189 
194 #define RCUTILS_LOG_CONDITION_THROTTLE_AFTER } \
195  }
196 
200 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_DEBUG)
202 // empty logging macros for severity DEBUG when being disabled at compile time
204 # define RCUTILS_LOG_DEBUG(format, ...)
205 # define RCUTILS_LOG_DEBUG_NAMED(name, format, ...)
207 # define RCUTILS_LOG_DEBUG_ONCE(format, ...)
209 # define RCUTILS_LOG_DEBUG_ONCE_NAMED(name, format, ...)
211 # define RCUTILS_LOG_DEBUG_EXPRESSION(expression, format, ...)
213 # define RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(expression, name, format, ...)
215 # define RCUTILS_LOG_DEBUG_FUNCTION(function, format, ...)
217 # define RCUTILS_LOG_DEBUG_FUNCTION_NAMED(function, name, format, ...)
219 # define RCUTILS_LOG_DEBUG_SKIPFIRST(format, ...)
221 # define RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED(name, format, ...)
223 # define RCUTILS_LOG_DEBUG_THROTTLE(time_source_type, duration, format, ...)
225 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
227 # define RCUTILS_LOG_DEBUG_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
229 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
231 
232 #else
233 
238 # define RCUTILS_LOG_DEBUG(...) \
239  RCUTILS_LOG_COND_NAMED( \
240  RCUTILS_LOG_SEVERITY_DEBUG, \
241  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
242  __VA_ARGS__)
243 
249 # define RCUTILS_LOG_DEBUG_NAMED(name, ...) \
250  RCUTILS_LOG_COND_NAMED( \
251  RCUTILS_LOG_SEVERITY_DEBUG, \
252  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
253  __VA_ARGS__)
254 
263 # define RCUTILS_LOG_DEBUG_ONCE(...) \
264  RCUTILS_LOG_COND_NAMED( \
265  RCUTILS_LOG_SEVERITY_DEBUG, \
266  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
267  __VA_ARGS__)
268 
278 # define RCUTILS_LOG_DEBUG_ONCE_NAMED(name, ...) \
279  RCUTILS_LOG_COND_NAMED( \
280  RCUTILS_LOG_SEVERITY_DEBUG, \
281  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
282  __VA_ARGS__)
283 
293 # define RCUTILS_LOG_DEBUG_EXPRESSION(expression, ...) \
294  RCUTILS_LOG_COND_NAMED( \
295  RCUTILS_LOG_SEVERITY_DEBUG, \
296  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
297  __VA_ARGS__)
298 
309 # define RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(expression, name, ...) \
310  RCUTILS_LOG_COND_NAMED( \
311  RCUTILS_LOG_SEVERITY_DEBUG, \
312  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
313  __VA_ARGS__)
314 
324 # define RCUTILS_LOG_DEBUG_FUNCTION(function, ...) \
325  RCUTILS_LOG_COND_NAMED( \
326  RCUTILS_LOG_SEVERITY_DEBUG, \
327  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
328  __VA_ARGS__)
329 
340 # define RCUTILS_LOG_DEBUG_FUNCTION_NAMED(function, name, ...) \
341  RCUTILS_LOG_COND_NAMED( \
342  RCUTILS_LOG_SEVERITY_DEBUG, \
343  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
344  __VA_ARGS__)
345 
354 # define RCUTILS_LOG_DEBUG_SKIPFIRST(...) \
355  RCUTILS_LOG_COND_NAMED( \
356  RCUTILS_LOG_SEVERITY_DEBUG, \
357  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
358  __VA_ARGS__)
359 
369 # define RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED(name, ...) \
370  RCUTILS_LOG_COND_NAMED( \
371  RCUTILS_LOG_SEVERITY_DEBUG, \
372  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
373  __VA_ARGS__)
374 
385 # define RCUTILS_LOG_DEBUG_THROTTLE(time_source_type, duration, ...) \
386  RCUTILS_LOG_COND_NAMED( \
387  RCUTILS_LOG_SEVERITY_DEBUG, \
388  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
389  __VA_ARGS__)
390 
402 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
403  RCUTILS_LOG_COND_NAMED( \
404  RCUTILS_LOG_SEVERITY_DEBUG, \
405  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
406  __VA_ARGS__)
407 
419 # define RCUTILS_LOG_DEBUG_THROTTLE_NAMED(time_source_type, duration, name, ...) \
420  RCUTILS_LOG_COND_NAMED( \
421  RCUTILS_LOG_SEVERITY_DEBUG, \
422  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
423  __VA_ARGS__)
424 
437 # define RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
438  RCUTILS_LOG_COND_NAMED( \
439  RCUTILS_LOG_SEVERITY_DEBUG, \
440  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, \
441  __VA_ARGS__)
442 #endif
443 
447 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_INFO)
449 // empty logging macros for severity INFO when being disabled at compile time
451 # define RCUTILS_LOG_INFO(format, ...)
452 # define RCUTILS_LOG_INFO_NAMED(name, format, ...)
454 # define RCUTILS_LOG_INFO_ONCE(format, ...)
456 # define RCUTILS_LOG_INFO_ONCE_NAMED(name, format, ...)
458 # define RCUTILS_LOG_INFO_EXPRESSION(expression, format, ...)
460 # define RCUTILS_LOG_INFO_EXPRESSION_NAMED(expression, name, format, ...)
462 # define RCUTILS_LOG_INFO_FUNCTION(function, format, ...)
464 # define RCUTILS_LOG_INFO_FUNCTION_NAMED(function, name, format, ...)
466 # define RCUTILS_LOG_INFO_SKIPFIRST(format, ...)
468 # define RCUTILS_LOG_INFO_SKIPFIRST_NAMED(name, format, ...)
470 # define RCUTILS_LOG_INFO_THROTTLE(time_source_type, duration, format, ...)
472 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
474 # define RCUTILS_LOG_INFO_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
476 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
478 
479 #else
480 
485 # define RCUTILS_LOG_INFO(...) \
486  RCUTILS_LOG_COND_NAMED( \
487  RCUTILS_LOG_SEVERITY_INFO, \
488  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
489  __VA_ARGS__)
490 
496 # define RCUTILS_LOG_INFO_NAMED(name, ...) \
497  RCUTILS_LOG_COND_NAMED( \
498  RCUTILS_LOG_SEVERITY_INFO, \
499  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
500  __VA_ARGS__)
501 
510 # define RCUTILS_LOG_INFO_ONCE(...) \
511  RCUTILS_LOG_COND_NAMED( \
512  RCUTILS_LOG_SEVERITY_INFO, \
513  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
514  __VA_ARGS__)
515 
525 # define RCUTILS_LOG_INFO_ONCE_NAMED(name, ...) \
526  RCUTILS_LOG_COND_NAMED( \
527  RCUTILS_LOG_SEVERITY_INFO, \
528  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
529  __VA_ARGS__)
530 
540 # define RCUTILS_LOG_INFO_EXPRESSION(expression, ...) \
541  RCUTILS_LOG_COND_NAMED( \
542  RCUTILS_LOG_SEVERITY_INFO, \
543  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
544  __VA_ARGS__)
545 
556 # define RCUTILS_LOG_INFO_EXPRESSION_NAMED(expression, name, ...) \
557  RCUTILS_LOG_COND_NAMED( \
558  RCUTILS_LOG_SEVERITY_INFO, \
559  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
560  __VA_ARGS__)
561 
571 # define RCUTILS_LOG_INFO_FUNCTION(function, ...) \
572  RCUTILS_LOG_COND_NAMED( \
573  RCUTILS_LOG_SEVERITY_INFO, \
574  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
575  __VA_ARGS__)
576 
587 # define RCUTILS_LOG_INFO_FUNCTION_NAMED(function, name, ...) \
588  RCUTILS_LOG_COND_NAMED( \
589  RCUTILS_LOG_SEVERITY_INFO, \
590  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
591  __VA_ARGS__)
592 
601 # define RCUTILS_LOG_INFO_SKIPFIRST(...) \
602  RCUTILS_LOG_COND_NAMED( \
603  RCUTILS_LOG_SEVERITY_INFO, \
604  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
605  __VA_ARGS__)
606 
616 # define RCUTILS_LOG_INFO_SKIPFIRST_NAMED(name, ...) \
617  RCUTILS_LOG_COND_NAMED( \
618  RCUTILS_LOG_SEVERITY_INFO, \
619  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
620  __VA_ARGS__)
621 
632 # define RCUTILS_LOG_INFO_THROTTLE(time_source_type, duration, ...) \
633  RCUTILS_LOG_COND_NAMED( \
634  RCUTILS_LOG_SEVERITY_INFO, \
635  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
636  __VA_ARGS__)
637 
649 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
650  RCUTILS_LOG_COND_NAMED( \
651  RCUTILS_LOG_SEVERITY_INFO, \
652  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
653  __VA_ARGS__)
654 
666 # define RCUTILS_LOG_INFO_THROTTLE_NAMED(time_source_type, duration, name, ...) \
667  RCUTILS_LOG_COND_NAMED( \
668  RCUTILS_LOG_SEVERITY_INFO, \
669  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
670  __VA_ARGS__)
671 
684 # define RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
685  RCUTILS_LOG_COND_NAMED( \
686  RCUTILS_LOG_SEVERITY_INFO, \
687  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, \
688  __VA_ARGS__)
689 #endif
690 
694 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_WARN)
696 // empty logging macros for severity WARN when being disabled at compile time
698 # define RCUTILS_LOG_WARN(format, ...)
699 # define RCUTILS_LOG_WARN_NAMED(name, format, ...)
701 # define RCUTILS_LOG_WARN_ONCE(format, ...)
703 # define RCUTILS_LOG_WARN_ONCE_NAMED(name, format, ...)
705 # define RCUTILS_LOG_WARN_EXPRESSION(expression, format, ...)
707 # define RCUTILS_LOG_WARN_EXPRESSION_NAMED(expression, name, format, ...)
709 # define RCUTILS_LOG_WARN_FUNCTION(function, format, ...)
711 # define RCUTILS_LOG_WARN_FUNCTION_NAMED(function, name, format, ...)
713 # define RCUTILS_LOG_WARN_SKIPFIRST(format, ...)
715 # define RCUTILS_LOG_WARN_SKIPFIRST_NAMED(name, format, ...)
717 # define RCUTILS_LOG_WARN_THROTTLE(time_source_type, duration, format, ...)
719 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
721 # define RCUTILS_LOG_WARN_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
723 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
725 
726 #else
727 
732 # define RCUTILS_LOG_WARN(...) \
733  RCUTILS_LOG_COND_NAMED( \
734  RCUTILS_LOG_SEVERITY_WARN, \
735  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
736  __VA_ARGS__)
737 
743 # define RCUTILS_LOG_WARN_NAMED(name, ...) \
744  RCUTILS_LOG_COND_NAMED( \
745  RCUTILS_LOG_SEVERITY_WARN, \
746  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
747  __VA_ARGS__)
748 
757 # define RCUTILS_LOG_WARN_ONCE(...) \
758  RCUTILS_LOG_COND_NAMED( \
759  RCUTILS_LOG_SEVERITY_WARN, \
760  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
761  __VA_ARGS__)
762 
772 # define RCUTILS_LOG_WARN_ONCE_NAMED(name, ...) \
773  RCUTILS_LOG_COND_NAMED( \
774  RCUTILS_LOG_SEVERITY_WARN, \
775  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
776  __VA_ARGS__)
777 
787 # define RCUTILS_LOG_WARN_EXPRESSION(expression, ...) \
788  RCUTILS_LOG_COND_NAMED( \
789  RCUTILS_LOG_SEVERITY_WARN, \
790  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
791  __VA_ARGS__)
792 
803 # define RCUTILS_LOG_WARN_EXPRESSION_NAMED(expression, name, ...) \
804  RCUTILS_LOG_COND_NAMED( \
805  RCUTILS_LOG_SEVERITY_WARN, \
806  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
807  __VA_ARGS__)
808 
818 # define RCUTILS_LOG_WARN_FUNCTION(function, ...) \
819  RCUTILS_LOG_COND_NAMED( \
820  RCUTILS_LOG_SEVERITY_WARN, \
821  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
822  __VA_ARGS__)
823 
834 # define RCUTILS_LOG_WARN_FUNCTION_NAMED(function, name, ...) \
835  RCUTILS_LOG_COND_NAMED( \
836  RCUTILS_LOG_SEVERITY_WARN, \
837  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
838  __VA_ARGS__)
839 
848 # define RCUTILS_LOG_WARN_SKIPFIRST(...) \
849  RCUTILS_LOG_COND_NAMED( \
850  RCUTILS_LOG_SEVERITY_WARN, \
851  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
852  __VA_ARGS__)
853 
863 # define RCUTILS_LOG_WARN_SKIPFIRST_NAMED(name, ...) \
864  RCUTILS_LOG_COND_NAMED( \
865  RCUTILS_LOG_SEVERITY_WARN, \
866  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
867  __VA_ARGS__)
868 
879 # define RCUTILS_LOG_WARN_THROTTLE(time_source_type, duration, ...) \
880  RCUTILS_LOG_COND_NAMED( \
881  RCUTILS_LOG_SEVERITY_WARN, \
882  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
883  __VA_ARGS__)
884 
896 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
897  RCUTILS_LOG_COND_NAMED( \
898  RCUTILS_LOG_SEVERITY_WARN, \
899  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
900  __VA_ARGS__)
901 
913 # define RCUTILS_LOG_WARN_THROTTLE_NAMED(time_source_type, duration, name, ...) \
914  RCUTILS_LOG_COND_NAMED( \
915  RCUTILS_LOG_SEVERITY_WARN, \
916  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
917  __VA_ARGS__)
918 
931 # define RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
932  RCUTILS_LOG_COND_NAMED( \
933  RCUTILS_LOG_SEVERITY_WARN, \
934  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, \
935  __VA_ARGS__)
936 #endif
937 
941 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_ERROR)
943 // empty logging macros for severity ERROR when being disabled at compile time
945 # define RCUTILS_LOG_ERROR(format, ...)
946 # define RCUTILS_LOG_ERROR_NAMED(name, format, ...)
948 # define RCUTILS_LOG_ERROR_ONCE(format, ...)
950 # define RCUTILS_LOG_ERROR_ONCE_NAMED(name, format, ...)
952 # define RCUTILS_LOG_ERROR_EXPRESSION(expression, format, ...)
954 # define RCUTILS_LOG_ERROR_EXPRESSION_NAMED(expression, name, format, ...)
956 # define RCUTILS_LOG_ERROR_FUNCTION(function, format, ...)
958 # define RCUTILS_LOG_ERROR_FUNCTION_NAMED(function, name, format, ...)
960 # define RCUTILS_LOG_ERROR_SKIPFIRST(format, ...)
962 # define RCUTILS_LOG_ERROR_SKIPFIRST_NAMED(name, format, ...)
964 # define RCUTILS_LOG_ERROR_THROTTLE(time_source_type, duration, format, ...)
966 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
968 # define RCUTILS_LOG_ERROR_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
970 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
972 
973 #else
974 
979 # define RCUTILS_LOG_ERROR(...) \
980  RCUTILS_LOG_COND_NAMED( \
981  RCUTILS_LOG_SEVERITY_ERROR, \
982  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
983  __VA_ARGS__)
984 
990 # define RCUTILS_LOG_ERROR_NAMED(name, ...) \
991  RCUTILS_LOG_COND_NAMED( \
992  RCUTILS_LOG_SEVERITY_ERROR, \
993  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
994  __VA_ARGS__)
995 
1004 # define RCUTILS_LOG_ERROR_ONCE(...) \
1005  RCUTILS_LOG_COND_NAMED( \
1006  RCUTILS_LOG_SEVERITY_ERROR, \
1007  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
1008  __VA_ARGS__)
1009 
1019 # define RCUTILS_LOG_ERROR_ONCE_NAMED(name, ...) \
1020  RCUTILS_LOG_COND_NAMED( \
1021  RCUTILS_LOG_SEVERITY_ERROR, \
1022  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
1023  __VA_ARGS__)
1024 
1034 # define RCUTILS_LOG_ERROR_EXPRESSION(expression, ...) \
1035  RCUTILS_LOG_COND_NAMED( \
1036  RCUTILS_LOG_SEVERITY_ERROR, \
1037  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
1038  __VA_ARGS__)
1039 
1050 # define RCUTILS_LOG_ERROR_EXPRESSION_NAMED(expression, name, ...) \
1051  RCUTILS_LOG_COND_NAMED( \
1052  RCUTILS_LOG_SEVERITY_ERROR, \
1053  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
1054  __VA_ARGS__)
1055 
1065 # define RCUTILS_LOG_ERROR_FUNCTION(function, ...) \
1066  RCUTILS_LOG_COND_NAMED( \
1067  RCUTILS_LOG_SEVERITY_ERROR, \
1068  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
1069  __VA_ARGS__)
1070 
1081 # define RCUTILS_LOG_ERROR_FUNCTION_NAMED(function, name, ...) \
1082  RCUTILS_LOG_COND_NAMED( \
1083  RCUTILS_LOG_SEVERITY_ERROR, \
1084  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
1085  __VA_ARGS__)
1086 
1095 # define RCUTILS_LOG_ERROR_SKIPFIRST(...) \
1096  RCUTILS_LOG_COND_NAMED( \
1097  RCUTILS_LOG_SEVERITY_ERROR, \
1098  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1099  __VA_ARGS__)
1100 
1110 # define RCUTILS_LOG_ERROR_SKIPFIRST_NAMED(name, ...) \
1111  RCUTILS_LOG_COND_NAMED( \
1112  RCUTILS_LOG_SEVERITY_ERROR, \
1113  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1114  __VA_ARGS__)
1115 
1126 # define RCUTILS_LOG_ERROR_THROTTLE(time_source_type, duration, ...) \
1127  RCUTILS_LOG_COND_NAMED( \
1128  RCUTILS_LOG_SEVERITY_ERROR, \
1129  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
1130  __VA_ARGS__)
1131 
1143 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
1144  RCUTILS_LOG_COND_NAMED( \
1145  RCUTILS_LOG_SEVERITY_ERROR, \
1146  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1147  __VA_ARGS__)
1148 
1160 # define RCUTILS_LOG_ERROR_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1161  RCUTILS_LOG_COND_NAMED( \
1162  RCUTILS_LOG_SEVERITY_ERROR, \
1163  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
1164  __VA_ARGS__)
1165 
1178 # define RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1179  RCUTILS_LOG_COND_NAMED( \
1180  RCUTILS_LOG_SEVERITY_ERROR, \
1181  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, \
1182  __VA_ARGS__)
1183 #endif
1184 
1188 #if (RCUTILS_LOG_MIN_SEVERITY > RCUTILS_LOG_MIN_SEVERITY_FATAL)
1190 // empty logging macros for severity FATAL when being disabled at compile time
1192 # define RCUTILS_LOG_FATAL(format, ...)
1193 # define RCUTILS_LOG_FATAL_NAMED(name, format, ...)
1195 # define RCUTILS_LOG_FATAL_ONCE(format, ...)
1197 # define RCUTILS_LOG_FATAL_ONCE_NAMED(name, format, ...)
1199 # define RCUTILS_LOG_FATAL_EXPRESSION(expression, format, ...)
1201 # define RCUTILS_LOG_FATAL_EXPRESSION_NAMED(expression, name, format, ...)
1203 # define RCUTILS_LOG_FATAL_FUNCTION(function, format, ...)
1205 # define RCUTILS_LOG_FATAL_FUNCTION_NAMED(function, name, format, ...)
1207 # define RCUTILS_LOG_FATAL_SKIPFIRST(format, ...)
1209 # define RCUTILS_LOG_FATAL_SKIPFIRST_NAMED(name, format, ...)
1211 # define RCUTILS_LOG_FATAL_THROTTLE(time_source_type, duration, format, ...)
1213 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE(time_source_type, duration, format, ...)
1215 # define RCUTILS_LOG_FATAL_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
1217 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, format, ...)
1219 
1220 #else
1221 
1226 # define RCUTILS_LOG_FATAL(...) \
1227  RCUTILS_LOG_COND_NAMED( \
1228  RCUTILS_LOG_SEVERITY_FATAL, \
1229  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, NULL, \
1230  __VA_ARGS__)
1231 
1237 # define RCUTILS_LOG_FATAL_NAMED(name, ...) \
1238  RCUTILS_LOG_COND_NAMED( \
1239  RCUTILS_LOG_SEVERITY_FATAL, \
1240  RCUTILS_LOG_CONDITION_EMPTY, RCUTILS_LOG_CONDITION_EMPTY, name, \
1241  __VA_ARGS__)
1242 
1251 # define RCUTILS_LOG_FATAL_ONCE(...) \
1252  RCUTILS_LOG_COND_NAMED( \
1253  RCUTILS_LOG_SEVERITY_FATAL, \
1254  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, NULL, \
1255  __VA_ARGS__)
1256 
1266 # define RCUTILS_LOG_FATAL_ONCE_NAMED(name, ...) \
1267  RCUTILS_LOG_COND_NAMED( \
1268  RCUTILS_LOG_SEVERITY_FATAL, \
1269  RCUTILS_LOG_CONDITION_ONCE_BEFORE, RCUTILS_LOG_CONDITION_ONCE_AFTER, name, \
1270  __VA_ARGS__)
1271 
1281 # define RCUTILS_LOG_FATAL_EXPRESSION(expression, ...) \
1282  RCUTILS_LOG_COND_NAMED( \
1283  RCUTILS_LOG_SEVERITY_FATAL, \
1284  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, NULL, \
1285  __VA_ARGS__)
1286 
1297 # define RCUTILS_LOG_FATAL_EXPRESSION_NAMED(expression, name, ...) \
1298  RCUTILS_LOG_COND_NAMED( \
1299  RCUTILS_LOG_SEVERITY_FATAL, \
1300  RCUTILS_LOG_CONDITION_EXPRESSION_BEFORE(expression), RCUTILS_LOG_CONDITION_EXPRESSION_AFTER, name, \
1301  __VA_ARGS__)
1302 
1312 # define RCUTILS_LOG_FATAL_FUNCTION(function, ...) \
1313  RCUTILS_LOG_COND_NAMED( \
1314  RCUTILS_LOG_SEVERITY_FATAL, \
1315  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, NULL, \
1316  __VA_ARGS__)
1317 
1328 # define RCUTILS_LOG_FATAL_FUNCTION_NAMED(function, name, ...) \
1329  RCUTILS_LOG_COND_NAMED( \
1330  RCUTILS_LOG_SEVERITY_FATAL, \
1331  RCUTILS_LOG_CONDITION_FUNCTION_BEFORE(function), RCUTILS_LOG_CONDITION_FUNCTION_AFTER, name, \
1332  __VA_ARGS__)
1333 
1342 # define RCUTILS_LOG_FATAL_SKIPFIRST(...) \
1343  RCUTILS_LOG_COND_NAMED( \
1344  RCUTILS_LOG_SEVERITY_FATAL, \
1345  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1346  __VA_ARGS__)
1347 
1357 # define RCUTILS_LOG_FATAL_SKIPFIRST_NAMED(name, ...) \
1358  RCUTILS_LOG_COND_NAMED( \
1359  RCUTILS_LOG_SEVERITY_FATAL, \
1360  RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, name, \
1361  __VA_ARGS__)
1362 
1373 # define RCUTILS_LOG_FATAL_THROTTLE(time_source_type, duration, ...) \
1374  RCUTILS_LOG_COND_NAMED( \
1375  RCUTILS_LOG_SEVERITY_FATAL, \
1376  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, NULL, \
1377  __VA_ARGS__)
1378 
1390 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE(time_source_type, duration, ...) \
1391  RCUTILS_LOG_COND_NAMED( \
1392  RCUTILS_LOG_SEVERITY_FATAL, \
1393  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration) RCUTILS_LOG_CONDITION_SKIPFIRST_BEFORE, RCUTILS_LOG_CONDITION_THROTTLE_AFTER RCUTILS_LOG_CONDITION_SKIPFIRST_AFTER, NULL, \
1394  __VA_ARGS__)
1395 
1407 # define RCUTILS_LOG_FATAL_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1408  RCUTILS_LOG_COND_NAMED( \
1409  RCUTILS_LOG_SEVERITY_FATAL, \
1410  RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(time_source_type, duration), RCUTILS_LOG_CONDITION_THROTTLE_AFTER, name, \
1411  __VA_ARGS__)
1412 
1425 # define RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED(time_source_type, duration, name, ...) \
1426  RCUTILS_LOG_COND_NAMED( \
1427  RCUTILS_LOG_SEVERITY_FATAL, \
1428  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, \
1429  __VA_ARGS__)
1430 #endif
1431 
1433 #if __cplusplus
1434 }
1435 #endif
1436 
1437 #endif // RCUTILS__LOGGING_MACROS_H_
bool(* RclLogFilter)()
Definition: logging_macros.h:129