rclcpp
master
C++ ROS Client Library API
include
rclcpp
logging.hpp
Go to the documentation of this file.
1
// generated from rclcpp/resource/logging.hpp.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
17
#ifndef RCLCPP__LOGGING_HPP_
18
#define RCLCPP__LOGGING_HPP_
19
20
#include <sstream>
21
#include <type_traits>
22
23
#include "
rclcpp/logger.hpp
"
24
#include "
rcutils/logging_macros.h
"
25
#include "
rclcpp/utilities.hpp
"
26
27
// These are used for compiling out logging macros lower than a minimum severity.
28
#define RCLCPP_LOG_MIN_SEVERITY_DEBUG 0
29
#define RCLCPP_LOG_MIN_SEVERITY_INFO 1
30
#define RCLCPP_LOG_MIN_SEVERITY_WARN 2
31
#define RCLCPP_LOG_MIN_SEVERITY_ERROR 3
32
#define RCLCPP_LOG_MIN_SEVERITY_FATAL 4
33
#define RCLCPP_LOG_MIN_SEVERITY_NONE 5
34
35
#define RCLCPP_FIRST_ARG(N, ...) N
36
#define RCLCPP_ALL_BUT_FIRST_ARGS(N, ...) __VA_ARGS__
37
44
#ifndef RCLCPP_LOG_MIN_SEVERITY
45
#define RCLCPP_LOG_MIN_SEVERITY RCLCPP_LOG_MIN_SEVERITY_DEBUG
46
#endif
47
50
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_DEBUG)
52
// empty logging macros for severity DEBUG when being disabled at compile time
54
#define RCLCPP_DEBUG(...)
55
#define RCLCPP_DEBUG_ONCE(...)
57
#define RCLCPP_DEBUG_EXPRESSION(...)
59
#define RCLCPP_DEBUG_FUNCTION(...)
61
#define RCLCPP_DEBUG_SKIPFIRST(...)
63
#define RCLCPP_DEBUG_THROTTLE(...)
65
#define RCLCPP_DEBUG_SKIPFIRST_THROTTLE(...)
67
#define RCLCPP_DEBUG_STREAM(...)
69
#define RCLCPP_DEBUG_STREAM_ONCE(...)
71
#define RCLCPP_DEBUG_STREAM_EXPRESSION(...)
73
#define RCLCPP_DEBUG_STREAM_FUNCTION(...)
75
#define RCLCPP_DEBUG_STREAM_SKIPFIRST(...)
77
#define RCLCPP_DEBUG_STREAM_THROTTLE(...)
79
#define RCLCPP_DEBUG_STREAM_SKIPFIRST_THROTTLE(...)
81
82
#else
83
// The RCLCPP_DEBUG macro is surrounded by do { .. } while (0)
84
// to implement the standard C macro idiom to make the macro safe in all
85
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
93
#define RCLCPP_DEBUG(logger, ...) \
94
do { \
95
static_assert( \
96
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
97
typename ::rclcpp::Logger>::value, \
98
"First argument to logging macros must be an rclcpp::Logger"); \
99
\
100
RCUTILS_LOG_DEBUG_NAMED( \
101
logger.get_name(), \
102
__VA_ARGS__); \
103
} while (0)
104
105
// The RCLCPP_DEBUG_ONCE macro is surrounded by do { .. } while (0)
106
// to implement the standard C macro idiom to make the macro safe in all
107
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
116
#define RCLCPP_DEBUG_ONCE(logger, ...) \
117
do { \
118
static_assert( \
119
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
120
typename ::rclcpp::Logger>::value, \
121
"First argument to logging macros must be an rclcpp::Logger"); \
122
\
123
RCUTILS_LOG_DEBUG_ONCE_NAMED( \
124
logger.get_name(), \
125
__VA_ARGS__); \
126
} while (0)
127
128
// The RCLCPP_DEBUG_EXPRESSION macro is surrounded by do { .. } while (0)
129
// to implement the standard C macro idiom to make the macro safe in all
130
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
140
#define RCLCPP_DEBUG_EXPRESSION(logger, expression, ...) \
141
do { \
142
static_assert( \
143
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
144
typename ::rclcpp::Logger>::value, \
145
"First argument to logging macros must be an rclcpp::Logger"); \
146
\
147
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED( \
148
expression, \
149
logger.get_name(), \
150
__VA_ARGS__); \
151
} while (0)
152
153
// The RCLCPP_DEBUG_FUNCTION macro is surrounded by do { .. } while (0)
154
// to implement the standard C macro idiom to make the macro safe in all
155
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
165
#define RCLCPP_DEBUG_FUNCTION(logger, function, ...) \
166
do { \
167
static_assert( \
168
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
169
typename ::rclcpp::Logger>::value, \
170
"First argument to logging macros must be an rclcpp::Logger"); \
171
\
172
RCUTILS_LOG_DEBUG_FUNCTION_NAMED( \
173
function, \
174
logger.get_name(), \
175
__VA_ARGS__); \
176
} while (0)
177
178
// The RCLCPP_DEBUG_SKIPFIRST macro is surrounded by do { .. } while (0)
179
// to implement the standard C macro idiom to make the macro safe in all
180
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
189
#define RCLCPP_DEBUG_SKIPFIRST(logger, ...) \
190
do { \
191
static_assert( \
192
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
193
typename ::rclcpp::Logger>::value, \
194
"First argument to logging macros must be an rclcpp::Logger"); \
195
\
196
RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED( \
197
logger.get_name(), \
198
__VA_ARGS__); \
199
} while (0)
200
201
// The RCLCPP_DEBUG_THROTTLE macro is surrounded by do { .. } while (0)
202
// to implement the standard C macro idiom to make the macro safe in all
203
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
214
#define RCLCPP_DEBUG_THROTTLE(logger, clock, duration, ...) \
215
do { \
216
static_assert( \
217
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
218
typename ::rclcpp::Logger>::value, \
219
"First argument to logging macros must be an rclcpp::Logger"); \
220
\
221
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
222
try { \
223
*time_point = c.now().nanoseconds(); \
224
} catch (...) { \
225
RCUTILS_SAFE_FWRITE_TO_STDERR( \
226
"[rclcpp|logging.hpp] RCLCPP_DEBUG_THROTTLE could not get current time stamp\n"); \
227
return RCUTILS_RET_ERROR; \
228
} \
229
return RCUTILS_RET_OK; \
230
}; \
231
\
232
RCUTILS_LOG_DEBUG_THROTTLE_NAMED( \
233
get_time_point, \
234
duration, \
235
logger.get_name(), \
236
__VA_ARGS__); \
237
} while (0)
238
239
// The RCLCPP_DEBUG_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
240
// to implement the standard C macro idiom to make the macro safe in all
241
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
253
#define RCLCPP_DEBUG_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
254
do { \
255
static_assert( \
256
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
257
typename ::rclcpp::Logger>::value, \
258
"First argument to logging macros must be an rclcpp::Logger"); \
259
\
260
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
261
try { \
262
*time_point = c.now().nanoseconds(); \
263
} catch (...) { \
264
RCUTILS_SAFE_FWRITE_TO_STDERR( \
265
"[rclcpp|logging.hpp] RCLCPP_DEBUG_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
266
return RCUTILS_RET_ERROR; \
267
} \
268
return RCUTILS_RET_OK; \
269
}; \
270
\
271
RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED( \
272
get_time_point, \
273
duration, \
274
logger.get_name(), \
275
__VA_ARGS__); \
276
} while (0)
277
278
// The RCLCPP_DEBUG_STREAM macro is surrounded by do { .. } while (0)
279
// to implement the standard C macro idiom to make the macro safe in all
280
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
287
#define RCLCPP_DEBUG_STREAM(logger, stream_arg) \
288
do { \
289
static_assert( \
290
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
291
typename ::rclcpp::Logger>::value, \
292
"First argument to logging macros must be an rclcpp::Logger"); \
293
\
294
std::stringstream ss; \
295
ss << stream_arg; \
296
RCUTILS_LOG_DEBUG_NAMED( \
297
logger.get_name(), \
298
"%s", ss.str().c_str()); \
299
} while (0)
300
301
// The RCLCPP_DEBUG_STREAM_ONCE macro is surrounded by do { .. } while (0)
302
// to implement the standard C macro idiom to make the macro safe in all
303
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
311
#define RCLCPP_DEBUG_STREAM_ONCE(logger, stream_arg) \
312
do { \
313
static_assert( \
314
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
315
typename ::rclcpp::Logger>::value, \
316
"First argument to logging macros must be an rclcpp::Logger"); \
317
\
318
std::stringstream ss; \
319
ss << stream_arg; \
320
RCUTILS_LOG_DEBUG_ONCE_NAMED( \
321
logger.get_name(), \
322
"%s", ss.str().c_str()); \
323
} while (0)
324
325
// The RCLCPP_DEBUG_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
326
// to implement the standard C macro idiom to make the macro safe in all
327
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
336
#define RCLCPP_DEBUG_STREAM_EXPRESSION(logger, expression, stream_arg) \
337
do { \
338
static_assert( \
339
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
340
typename ::rclcpp::Logger>::value, \
341
"First argument to logging macros must be an rclcpp::Logger"); \
342
\
343
std::stringstream ss; \
344
ss << stream_arg; \
345
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED( \
346
expression, \
347
logger.get_name(), \
348
"%s", ss.str().c_str()); \
349
} while (0)
350
351
// The RCLCPP_DEBUG_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
352
// to implement the standard C macro idiom to make the macro safe in all
353
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
362
#define RCLCPP_DEBUG_STREAM_FUNCTION(logger, function, stream_arg) \
363
do { \
364
static_assert( \
365
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
366
typename ::rclcpp::Logger>::value, \
367
"First argument to logging macros must be an rclcpp::Logger"); \
368
\
369
std::stringstream ss; \
370
ss << stream_arg; \
371
RCUTILS_LOG_DEBUG_FUNCTION_NAMED( \
372
function, \
373
logger.get_name(), \
374
"%s", ss.str().c_str()); \
375
} while (0)
376
377
// The RCLCPP_DEBUG_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
378
// to implement the standard C macro idiom to make the macro safe in all
379
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
387
#define RCLCPP_DEBUG_STREAM_SKIPFIRST(logger, stream_arg) \
388
do { \
389
static_assert( \
390
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
391
typename ::rclcpp::Logger>::value, \
392
"First argument to logging macros must be an rclcpp::Logger"); \
393
\
394
std::stringstream ss; \
395
ss << stream_arg; \
396
RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED( \
397
logger.get_name(), \
398
"%s", ss.str().c_str()); \
399
} while (0)
400
401
// The RCLCPP_DEBUG_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
402
// to implement the standard C macro idiom to make the macro safe in all
403
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
413
#define RCLCPP_DEBUG_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
414
do { \
415
static_assert( \
416
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
417
typename ::rclcpp::Logger>::value, \
418
"First argument to logging macros must be an rclcpp::Logger"); \
419
\
420
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
421
try { \
422
*time_point = c.now().nanoseconds(); \
423
} catch (...) { \
424
RCUTILS_SAFE_FWRITE_TO_STDERR( \
425
"[rclcpp|logging.hpp] RCLCPP_DEBUG_STREAM_THROTTLE could not get current time stamp\n"); \
426
return RCUTILS_RET_ERROR; \
427
} \
428
return RCUTILS_RET_OK; \
429
}; \
430
\
431
std::stringstream ss; \
432
ss << stream_arg; \
433
RCUTILS_LOG_DEBUG_THROTTLE_NAMED( \
434
get_time_point, \
435
duration, \
436
logger.get_name(), \
437
"%s", ss.str().c_str()); \
438
} while (0)
439
440
// The RCLCPP_DEBUG_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
441
// to implement the standard C macro idiom to make the macro safe in all
442
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
453
#define RCLCPP_DEBUG_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
454
do { \
455
static_assert( \
456
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
457
typename ::rclcpp::Logger>::value, \
458
"First argument to logging macros must be an rclcpp::Logger"); \
459
\
460
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
461
try { \
462
*time_point = c.now().nanoseconds(); \
463
} catch (...) { \
464
RCUTILS_SAFE_FWRITE_TO_STDERR( \
465
"[rclcpp|logging.hpp] RCLCPP_DEBUG_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
466
return RCUTILS_RET_ERROR; \
467
} \
468
return RCUTILS_RET_OK; \
469
}; \
470
\
471
std::stringstream ss; \
472
ss << stream_arg; \
473
RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED( \
474
get_time_point, \
475
duration, \
476
logger.get_name(), \
477
"%s", ss.str().c_str()); \
478
} while (0)
479
480
#endif
481
485
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_INFO)
487
// empty logging macros for severity INFO when being disabled at compile time
489
#define RCLCPP_INFO(...)
490
#define RCLCPP_INFO_ONCE(...)
492
#define RCLCPP_INFO_EXPRESSION(...)
494
#define RCLCPP_INFO_FUNCTION(...)
496
#define RCLCPP_INFO_SKIPFIRST(...)
498
#define RCLCPP_INFO_THROTTLE(...)
500
#define RCLCPP_INFO_SKIPFIRST_THROTTLE(...)
502
#define RCLCPP_INFO_STREAM(...)
504
#define RCLCPP_INFO_STREAM_ONCE(...)
506
#define RCLCPP_INFO_STREAM_EXPRESSION(...)
508
#define RCLCPP_INFO_STREAM_FUNCTION(...)
510
#define RCLCPP_INFO_STREAM_SKIPFIRST(...)
512
#define RCLCPP_INFO_STREAM_THROTTLE(...)
514
#define RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE(...)
516
517
#else
518
// The RCLCPP_INFO macro is surrounded by do { .. } while (0)
519
// to implement the standard C macro idiom to make the macro safe in all
520
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
528
#define RCLCPP_INFO(logger, ...) \
529
do { \
530
static_assert( \
531
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
532
typename ::rclcpp::Logger>::value, \
533
"First argument to logging macros must be an rclcpp::Logger"); \
534
\
535
RCUTILS_LOG_INFO_NAMED( \
536
logger.get_name(), \
537
__VA_ARGS__); \
538
} while (0)
539
540
// The RCLCPP_INFO_ONCE macro is surrounded by do { .. } while (0)
541
// to implement the standard C macro idiom to make the macro safe in all
542
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
551
#define RCLCPP_INFO_ONCE(logger, ...) \
552
do { \
553
static_assert( \
554
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
555
typename ::rclcpp::Logger>::value, \
556
"First argument to logging macros must be an rclcpp::Logger"); \
557
\
558
RCUTILS_LOG_INFO_ONCE_NAMED( \
559
logger.get_name(), \
560
__VA_ARGS__); \
561
} while (0)
562
563
// The RCLCPP_INFO_EXPRESSION macro is surrounded by do { .. } while (0)
564
// to implement the standard C macro idiom to make the macro safe in all
565
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
575
#define RCLCPP_INFO_EXPRESSION(logger, expression, ...) \
576
do { \
577
static_assert( \
578
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
579
typename ::rclcpp::Logger>::value, \
580
"First argument to logging macros must be an rclcpp::Logger"); \
581
\
582
RCUTILS_LOG_INFO_EXPRESSION_NAMED( \
583
expression, \
584
logger.get_name(), \
585
__VA_ARGS__); \
586
} while (0)
587
588
// The RCLCPP_INFO_FUNCTION macro is surrounded by do { .. } while (0)
589
// to implement the standard C macro idiom to make the macro safe in all
590
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
600
#define RCLCPP_INFO_FUNCTION(logger, function, ...) \
601
do { \
602
static_assert( \
603
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
604
typename ::rclcpp::Logger>::value, \
605
"First argument to logging macros must be an rclcpp::Logger"); \
606
\
607
RCUTILS_LOG_INFO_FUNCTION_NAMED( \
608
function, \
609
logger.get_name(), \
610
__VA_ARGS__); \
611
} while (0)
612
613
// The RCLCPP_INFO_SKIPFIRST macro is surrounded by do { .. } while (0)
614
// to implement the standard C macro idiom to make the macro safe in all
615
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
624
#define RCLCPP_INFO_SKIPFIRST(logger, ...) \
625
do { \
626
static_assert( \
627
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
628
typename ::rclcpp::Logger>::value, \
629
"First argument to logging macros must be an rclcpp::Logger"); \
630
\
631
RCUTILS_LOG_INFO_SKIPFIRST_NAMED( \
632
logger.get_name(), \
633
__VA_ARGS__); \
634
} while (0)
635
636
// The RCLCPP_INFO_THROTTLE macro is surrounded by do { .. } while (0)
637
// to implement the standard C macro idiom to make the macro safe in all
638
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
649
#define RCLCPP_INFO_THROTTLE(logger, clock, duration, ...) \
650
do { \
651
static_assert( \
652
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
653
typename ::rclcpp::Logger>::value, \
654
"First argument to logging macros must be an rclcpp::Logger"); \
655
\
656
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
657
try { \
658
*time_point = c.now().nanoseconds(); \
659
} catch (...) { \
660
RCUTILS_SAFE_FWRITE_TO_STDERR( \
661
"[rclcpp|logging.hpp] RCLCPP_INFO_THROTTLE could not get current time stamp\n"); \
662
return RCUTILS_RET_ERROR; \
663
} \
664
return RCUTILS_RET_OK; \
665
}; \
666
\
667
RCUTILS_LOG_INFO_THROTTLE_NAMED( \
668
get_time_point, \
669
duration, \
670
logger.get_name(), \
671
__VA_ARGS__); \
672
} while (0)
673
674
// The RCLCPP_INFO_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
675
// to implement the standard C macro idiom to make the macro safe in all
676
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
688
#define RCLCPP_INFO_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
689
do { \
690
static_assert( \
691
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
692
typename ::rclcpp::Logger>::value, \
693
"First argument to logging macros must be an rclcpp::Logger"); \
694
\
695
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
696
try { \
697
*time_point = c.now().nanoseconds(); \
698
} catch (...) { \
699
RCUTILS_SAFE_FWRITE_TO_STDERR( \
700
"[rclcpp|logging.hpp] RCLCPP_INFO_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
701
return RCUTILS_RET_ERROR; \
702
} \
703
return RCUTILS_RET_OK; \
704
}; \
705
\
706
RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED( \
707
get_time_point, \
708
duration, \
709
logger.get_name(), \
710
__VA_ARGS__); \
711
} while (0)
712
713
// The RCLCPP_INFO_STREAM macro is surrounded by do { .. } while (0)
714
// to implement the standard C macro idiom to make the macro safe in all
715
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
722
#define RCLCPP_INFO_STREAM(logger, stream_arg) \
723
do { \
724
static_assert( \
725
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
726
typename ::rclcpp::Logger>::value, \
727
"First argument to logging macros must be an rclcpp::Logger"); \
728
\
729
std::stringstream ss; \
730
ss << stream_arg; \
731
RCUTILS_LOG_INFO_NAMED( \
732
logger.get_name(), \
733
"%s", ss.str().c_str()); \
734
} while (0)
735
736
// The RCLCPP_INFO_STREAM_ONCE macro is surrounded by do { .. } while (0)
737
// to implement the standard C macro idiom to make the macro safe in all
738
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
746
#define RCLCPP_INFO_STREAM_ONCE(logger, stream_arg) \
747
do { \
748
static_assert( \
749
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
750
typename ::rclcpp::Logger>::value, \
751
"First argument to logging macros must be an rclcpp::Logger"); \
752
\
753
std::stringstream ss; \
754
ss << stream_arg; \
755
RCUTILS_LOG_INFO_ONCE_NAMED( \
756
logger.get_name(), \
757
"%s", ss.str().c_str()); \
758
} while (0)
759
760
// The RCLCPP_INFO_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
761
// to implement the standard C macro idiom to make the macro safe in all
762
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
771
#define RCLCPP_INFO_STREAM_EXPRESSION(logger, expression, stream_arg) \
772
do { \
773
static_assert( \
774
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
775
typename ::rclcpp::Logger>::value, \
776
"First argument to logging macros must be an rclcpp::Logger"); \
777
\
778
std::stringstream ss; \
779
ss << stream_arg; \
780
RCUTILS_LOG_INFO_EXPRESSION_NAMED( \
781
expression, \
782
logger.get_name(), \
783
"%s", ss.str().c_str()); \
784
} while (0)
785
786
// The RCLCPP_INFO_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
787
// to implement the standard C macro idiom to make the macro safe in all
788
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
797
#define RCLCPP_INFO_STREAM_FUNCTION(logger, function, stream_arg) \
798
do { \
799
static_assert( \
800
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
801
typename ::rclcpp::Logger>::value, \
802
"First argument to logging macros must be an rclcpp::Logger"); \
803
\
804
std::stringstream ss; \
805
ss << stream_arg; \
806
RCUTILS_LOG_INFO_FUNCTION_NAMED( \
807
function, \
808
logger.get_name(), \
809
"%s", ss.str().c_str()); \
810
} while (0)
811
812
// The RCLCPP_INFO_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
813
// to implement the standard C macro idiom to make the macro safe in all
814
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
822
#define RCLCPP_INFO_STREAM_SKIPFIRST(logger, stream_arg) \
823
do { \
824
static_assert( \
825
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
826
typename ::rclcpp::Logger>::value, \
827
"First argument to logging macros must be an rclcpp::Logger"); \
828
\
829
std::stringstream ss; \
830
ss << stream_arg; \
831
RCUTILS_LOG_INFO_SKIPFIRST_NAMED( \
832
logger.get_name(), \
833
"%s", ss.str().c_str()); \
834
} while (0)
835
836
// The RCLCPP_INFO_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
837
// to implement the standard C macro idiom to make the macro safe in all
838
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
848
#define RCLCPP_INFO_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
849
do { \
850
static_assert( \
851
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
852
typename ::rclcpp::Logger>::value, \
853
"First argument to logging macros must be an rclcpp::Logger"); \
854
\
855
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
856
try { \
857
*time_point = c.now().nanoseconds(); \
858
} catch (...) { \
859
RCUTILS_SAFE_FWRITE_TO_STDERR( \
860
"[rclcpp|logging.hpp] RCLCPP_INFO_STREAM_THROTTLE could not get current time stamp\n"); \
861
return RCUTILS_RET_ERROR; \
862
} \
863
return RCUTILS_RET_OK; \
864
}; \
865
\
866
std::stringstream ss; \
867
ss << stream_arg; \
868
RCUTILS_LOG_INFO_THROTTLE_NAMED( \
869
get_time_point, \
870
duration, \
871
logger.get_name(), \
872
"%s", ss.str().c_str()); \
873
} while (0)
874
875
// The RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
876
// to implement the standard C macro idiom to make the macro safe in all
877
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
888
#define RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
889
do { \
890
static_assert( \
891
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
892
typename ::rclcpp::Logger>::value, \
893
"First argument to logging macros must be an rclcpp::Logger"); \
894
\
895
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
896
try { \
897
*time_point = c.now().nanoseconds(); \
898
} catch (...) { \
899
RCUTILS_SAFE_FWRITE_TO_STDERR( \
900
"[rclcpp|logging.hpp] RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
901
return RCUTILS_RET_ERROR; \
902
} \
903
return RCUTILS_RET_OK; \
904
}; \
905
\
906
std::stringstream ss; \
907
ss << stream_arg; \
908
RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED( \
909
get_time_point, \
910
duration, \
911
logger.get_name(), \
912
"%s", ss.str().c_str()); \
913
} while (0)
914
915
#endif
916
920
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_WARN)
922
// empty logging macros for severity WARN when being disabled at compile time
924
#define RCLCPP_WARN(...)
925
#define RCLCPP_WARN_ONCE(...)
927
#define RCLCPP_WARN_EXPRESSION(...)
929
#define RCLCPP_WARN_FUNCTION(...)
931
#define RCLCPP_WARN_SKIPFIRST(...)
933
#define RCLCPP_WARN_THROTTLE(...)
935
#define RCLCPP_WARN_SKIPFIRST_THROTTLE(...)
937
#define RCLCPP_WARN_STREAM(...)
939
#define RCLCPP_WARN_STREAM_ONCE(...)
941
#define RCLCPP_WARN_STREAM_EXPRESSION(...)
943
#define RCLCPP_WARN_STREAM_FUNCTION(...)
945
#define RCLCPP_WARN_STREAM_SKIPFIRST(...)
947
#define RCLCPP_WARN_STREAM_THROTTLE(...)
949
#define RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE(...)
951
952
#else
953
// The RCLCPP_WARN macro is surrounded by do { .. } while (0)
954
// to implement the standard C macro idiom to make the macro safe in all
955
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
963
#define RCLCPP_WARN(logger, ...) \
964
do { \
965
static_assert( \
966
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
967
typename ::rclcpp::Logger>::value, \
968
"First argument to logging macros must be an rclcpp::Logger"); \
969
\
970
RCUTILS_LOG_WARN_NAMED( \
971
logger.get_name(), \
972
__VA_ARGS__); \
973
} while (0)
974
975
// The RCLCPP_WARN_ONCE macro is surrounded by do { .. } while (0)
976
// to implement the standard C macro idiom to make the macro safe in all
977
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
986
#define RCLCPP_WARN_ONCE(logger, ...) \
987
do { \
988
static_assert( \
989
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
990
typename ::rclcpp::Logger>::value, \
991
"First argument to logging macros must be an rclcpp::Logger"); \
992
\
993
RCUTILS_LOG_WARN_ONCE_NAMED( \
994
logger.get_name(), \
995
__VA_ARGS__); \
996
} while (0)
997
998
// The RCLCPP_WARN_EXPRESSION macro is surrounded by do { .. } while (0)
999
// to implement the standard C macro idiom to make the macro safe in all
1000
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1010
#define RCLCPP_WARN_EXPRESSION(logger, expression, ...) \
1011
do { \
1012
static_assert( \
1013
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1014
typename ::rclcpp::Logger>::value, \
1015
"First argument to logging macros must be an rclcpp::Logger"); \
1016
\
1017
RCUTILS_LOG_WARN_EXPRESSION_NAMED( \
1018
expression, \
1019
logger.get_name(), \
1020
__VA_ARGS__); \
1021
} while (0)
1022
1023
// The RCLCPP_WARN_FUNCTION macro is surrounded by do { .. } while (0)
1024
// to implement the standard C macro idiom to make the macro safe in all
1025
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1035
#define RCLCPP_WARN_FUNCTION(logger, function, ...) \
1036
do { \
1037
static_assert( \
1038
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1039
typename ::rclcpp::Logger>::value, \
1040
"First argument to logging macros must be an rclcpp::Logger"); \
1041
\
1042
RCUTILS_LOG_WARN_FUNCTION_NAMED( \
1043
function, \
1044
logger.get_name(), \
1045
__VA_ARGS__); \
1046
} while (0)
1047
1048
// The RCLCPP_WARN_SKIPFIRST macro is surrounded by do { .. } while (0)
1049
// to implement the standard C macro idiom to make the macro safe in all
1050
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1059
#define RCLCPP_WARN_SKIPFIRST(logger, ...) \
1060
do { \
1061
static_assert( \
1062
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1063
typename ::rclcpp::Logger>::value, \
1064
"First argument to logging macros must be an rclcpp::Logger"); \
1065
\
1066
RCUTILS_LOG_WARN_SKIPFIRST_NAMED( \
1067
logger.get_name(), \
1068
__VA_ARGS__); \
1069
} while (0)
1070
1071
// The RCLCPP_WARN_THROTTLE macro is surrounded by do { .. } while (0)
1072
// to implement the standard C macro idiom to make the macro safe in all
1073
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1084
#define RCLCPP_WARN_THROTTLE(logger, clock, duration, ...) \
1085
do { \
1086
static_assert( \
1087
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1088
typename ::rclcpp::Logger>::value, \
1089
"First argument to logging macros must be an rclcpp::Logger"); \
1090
\
1091
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1092
try { \
1093
*time_point = c.now().nanoseconds(); \
1094
} catch (...) { \
1095
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1096
"[rclcpp|logging.hpp] RCLCPP_WARN_THROTTLE could not get current time stamp\n"); \
1097
return RCUTILS_RET_ERROR; \
1098
} \
1099
return RCUTILS_RET_OK; \
1100
}; \
1101
\
1102
RCUTILS_LOG_WARN_THROTTLE_NAMED( \
1103
get_time_point, \
1104
duration, \
1105
logger.get_name(), \
1106
__VA_ARGS__); \
1107
} while (0)
1108
1109
// The RCLCPP_WARN_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1110
// to implement the standard C macro idiom to make the macro safe in all
1111
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1123
#define RCLCPP_WARN_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
1124
do { \
1125
static_assert( \
1126
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1127
typename ::rclcpp::Logger>::value, \
1128
"First argument to logging macros must be an rclcpp::Logger"); \
1129
\
1130
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1131
try { \
1132
*time_point = c.now().nanoseconds(); \
1133
} catch (...) { \
1134
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1135
"[rclcpp|logging.hpp] RCLCPP_WARN_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1136
return RCUTILS_RET_ERROR; \
1137
} \
1138
return RCUTILS_RET_OK; \
1139
}; \
1140
\
1141
RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED( \
1142
get_time_point, \
1143
duration, \
1144
logger.get_name(), \
1145
__VA_ARGS__); \
1146
} while (0)
1147
1148
// The RCLCPP_WARN_STREAM macro is surrounded by do { .. } while (0)
1149
// to implement the standard C macro idiom to make the macro safe in all
1150
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1157
#define RCLCPP_WARN_STREAM(logger, stream_arg) \
1158
do { \
1159
static_assert( \
1160
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1161
typename ::rclcpp::Logger>::value, \
1162
"First argument to logging macros must be an rclcpp::Logger"); \
1163
\
1164
std::stringstream ss; \
1165
ss << stream_arg; \
1166
RCUTILS_LOG_WARN_NAMED( \
1167
logger.get_name(), \
1168
"%s", ss.str().c_str()); \
1169
} while (0)
1170
1171
// The RCLCPP_WARN_STREAM_ONCE macro is surrounded by do { .. } while (0)
1172
// to implement the standard C macro idiom to make the macro safe in all
1173
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1181
#define RCLCPP_WARN_STREAM_ONCE(logger, stream_arg) \
1182
do { \
1183
static_assert( \
1184
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1185
typename ::rclcpp::Logger>::value, \
1186
"First argument to logging macros must be an rclcpp::Logger"); \
1187
\
1188
std::stringstream ss; \
1189
ss << stream_arg; \
1190
RCUTILS_LOG_WARN_ONCE_NAMED( \
1191
logger.get_name(), \
1192
"%s", ss.str().c_str()); \
1193
} while (0)
1194
1195
// The RCLCPP_WARN_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
1196
// to implement the standard C macro idiom to make the macro safe in all
1197
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1206
#define RCLCPP_WARN_STREAM_EXPRESSION(logger, expression, stream_arg) \
1207
do { \
1208
static_assert( \
1209
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1210
typename ::rclcpp::Logger>::value, \
1211
"First argument to logging macros must be an rclcpp::Logger"); \
1212
\
1213
std::stringstream ss; \
1214
ss << stream_arg; \
1215
RCUTILS_LOG_WARN_EXPRESSION_NAMED( \
1216
expression, \
1217
logger.get_name(), \
1218
"%s", ss.str().c_str()); \
1219
} while (0)
1220
1221
// The RCLCPP_WARN_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
1222
// to implement the standard C macro idiom to make the macro safe in all
1223
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1232
#define RCLCPP_WARN_STREAM_FUNCTION(logger, function, stream_arg) \
1233
do { \
1234
static_assert( \
1235
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1236
typename ::rclcpp::Logger>::value, \
1237
"First argument to logging macros must be an rclcpp::Logger"); \
1238
\
1239
std::stringstream ss; \
1240
ss << stream_arg; \
1241
RCUTILS_LOG_WARN_FUNCTION_NAMED( \
1242
function, \
1243
logger.get_name(), \
1244
"%s", ss.str().c_str()); \
1245
} while (0)
1246
1247
// The RCLCPP_WARN_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
1248
// to implement the standard C macro idiom to make the macro safe in all
1249
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1257
#define RCLCPP_WARN_STREAM_SKIPFIRST(logger, stream_arg) \
1258
do { \
1259
static_assert( \
1260
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1261
typename ::rclcpp::Logger>::value, \
1262
"First argument to logging macros must be an rclcpp::Logger"); \
1263
\
1264
std::stringstream ss; \
1265
ss << stream_arg; \
1266
RCUTILS_LOG_WARN_SKIPFIRST_NAMED( \
1267
logger.get_name(), \
1268
"%s", ss.str().c_str()); \
1269
} while (0)
1270
1271
// The RCLCPP_WARN_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
1272
// to implement the standard C macro idiom to make the macro safe in all
1273
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1283
#define RCLCPP_WARN_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
1284
do { \
1285
static_assert( \
1286
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1287
typename ::rclcpp::Logger>::value, \
1288
"First argument to logging macros must be an rclcpp::Logger"); \
1289
\
1290
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1291
try { \
1292
*time_point = c.now().nanoseconds(); \
1293
} catch (...) { \
1294
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1295
"[rclcpp|logging.hpp] RCLCPP_WARN_STREAM_THROTTLE could not get current time stamp\n"); \
1296
return RCUTILS_RET_ERROR; \
1297
} \
1298
return RCUTILS_RET_OK; \
1299
}; \
1300
\
1301
std::stringstream ss; \
1302
ss << stream_arg; \
1303
RCUTILS_LOG_WARN_THROTTLE_NAMED( \
1304
get_time_point, \
1305
duration, \
1306
logger.get_name(), \
1307
"%s", ss.str().c_str()); \
1308
} while (0)
1309
1310
// The RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1311
// to implement the standard C macro idiom to make the macro safe in all
1312
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1323
#define RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
1324
do { \
1325
static_assert( \
1326
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1327
typename ::rclcpp::Logger>::value, \
1328
"First argument to logging macros must be an rclcpp::Logger"); \
1329
\
1330
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1331
try { \
1332
*time_point = c.now().nanoseconds(); \
1333
} catch (...) { \
1334
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1335
"[rclcpp|logging.hpp] RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1336
return RCUTILS_RET_ERROR; \
1337
} \
1338
return RCUTILS_RET_OK; \
1339
}; \
1340
\
1341
std::stringstream ss; \
1342
ss << stream_arg; \
1343
RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED( \
1344
get_time_point, \
1345
duration, \
1346
logger.get_name(), \
1347
"%s", ss.str().c_str()); \
1348
} while (0)
1349
1350
#endif
1351
1355
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_ERROR)
1357
// empty logging macros for severity ERROR when being disabled at compile time
1359
#define RCLCPP_ERROR(...)
1360
#define RCLCPP_ERROR_ONCE(...)
1362
#define RCLCPP_ERROR_EXPRESSION(...)
1364
#define RCLCPP_ERROR_FUNCTION(...)
1366
#define RCLCPP_ERROR_SKIPFIRST(...)
1368
#define RCLCPP_ERROR_THROTTLE(...)
1370
#define RCLCPP_ERROR_SKIPFIRST_THROTTLE(...)
1372
#define RCLCPP_ERROR_STREAM(...)
1374
#define RCLCPP_ERROR_STREAM_ONCE(...)
1376
#define RCLCPP_ERROR_STREAM_EXPRESSION(...)
1378
#define RCLCPP_ERROR_STREAM_FUNCTION(...)
1380
#define RCLCPP_ERROR_STREAM_SKIPFIRST(...)
1382
#define RCLCPP_ERROR_STREAM_THROTTLE(...)
1384
#define RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE(...)
1386
1387
#else
1388
// The RCLCPP_ERROR macro is surrounded by do { .. } while (0)
1389
// to implement the standard C macro idiom to make the macro safe in all
1390
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1398
#define RCLCPP_ERROR(logger, ...) \
1399
do { \
1400
static_assert( \
1401
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1402
typename ::rclcpp::Logger>::value, \
1403
"First argument to logging macros must be an rclcpp::Logger"); \
1404
\
1405
RCUTILS_LOG_ERROR_NAMED( \
1406
logger.get_name(), \
1407
__VA_ARGS__); \
1408
} while (0)
1409
1410
// The RCLCPP_ERROR_ONCE macro is surrounded by do { .. } while (0)
1411
// to implement the standard C macro idiom to make the macro safe in all
1412
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1421
#define RCLCPP_ERROR_ONCE(logger, ...) \
1422
do { \
1423
static_assert( \
1424
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1425
typename ::rclcpp::Logger>::value, \
1426
"First argument to logging macros must be an rclcpp::Logger"); \
1427
\
1428
RCUTILS_LOG_ERROR_ONCE_NAMED( \
1429
logger.get_name(), \
1430
__VA_ARGS__); \
1431
} while (0)
1432
1433
// The RCLCPP_ERROR_EXPRESSION macro is surrounded by do { .. } while (0)
1434
// to implement the standard C macro idiom to make the macro safe in all
1435
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1445
#define RCLCPP_ERROR_EXPRESSION(logger, expression, ...) \
1446
do { \
1447
static_assert( \
1448
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1449
typename ::rclcpp::Logger>::value, \
1450
"First argument to logging macros must be an rclcpp::Logger"); \
1451
\
1452
RCUTILS_LOG_ERROR_EXPRESSION_NAMED( \
1453
expression, \
1454
logger.get_name(), \
1455
__VA_ARGS__); \
1456
} while (0)
1457
1458
// The RCLCPP_ERROR_FUNCTION macro is surrounded by do { .. } while (0)
1459
// to implement the standard C macro idiom to make the macro safe in all
1460
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1470
#define RCLCPP_ERROR_FUNCTION(logger, function, ...) \
1471
do { \
1472
static_assert( \
1473
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1474
typename ::rclcpp::Logger>::value, \
1475
"First argument to logging macros must be an rclcpp::Logger"); \
1476
\
1477
RCUTILS_LOG_ERROR_FUNCTION_NAMED( \
1478
function, \
1479
logger.get_name(), \
1480
__VA_ARGS__); \
1481
} while (0)
1482
1483
// The RCLCPP_ERROR_SKIPFIRST macro is surrounded by do { .. } while (0)
1484
// to implement the standard C macro idiom to make the macro safe in all
1485
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1494
#define RCLCPP_ERROR_SKIPFIRST(logger, ...) \
1495
do { \
1496
static_assert( \
1497
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1498
typename ::rclcpp::Logger>::value, \
1499
"First argument to logging macros must be an rclcpp::Logger"); \
1500
\
1501
RCUTILS_LOG_ERROR_SKIPFIRST_NAMED( \
1502
logger.get_name(), \
1503
__VA_ARGS__); \
1504
} while (0)
1505
1506
// The RCLCPP_ERROR_THROTTLE macro is surrounded by do { .. } while (0)
1507
// to implement the standard C macro idiom to make the macro safe in all
1508
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1519
#define RCLCPP_ERROR_THROTTLE(logger, clock, duration, ...) \
1520
do { \
1521
static_assert( \
1522
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1523
typename ::rclcpp::Logger>::value, \
1524
"First argument to logging macros must be an rclcpp::Logger"); \
1525
\
1526
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1527
try { \
1528
*time_point = c.now().nanoseconds(); \
1529
} catch (...) { \
1530
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1531
"[rclcpp|logging.hpp] RCLCPP_ERROR_THROTTLE could not get current time stamp\n"); \
1532
return RCUTILS_RET_ERROR; \
1533
} \
1534
return RCUTILS_RET_OK; \
1535
}; \
1536
\
1537
RCUTILS_LOG_ERROR_THROTTLE_NAMED( \
1538
get_time_point, \
1539
duration, \
1540
logger.get_name(), \
1541
__VA_ARGS__); \
1542
} while (0)
1543
1544
// The RCLCPP_ERROR_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1545
// to implement the standard C macro idiom to make the macro safe in all
1546
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1558
#define RCLCPP_ERROR_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
1559
do { \
1560
static_assert( \
1561
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1562
typename ::rclcpp::Logger>::value, \
1563
"First argument to logging macros must be an rclcpp::Logger"); \
1564
\
1565
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1566
try { \
1567
*time_point = c.now().nanoseconds(); \
1568
} catch (...) { \
1569
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1570
"[rclcpp|logging.hpp] RCLCPP_ERROR_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1571
return RCUTILS_RET_ERROR; \
1572
} \
1573
return RCUTILS_RET_OK; \
1574
}; \
1575
\
1576
RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED( \
1577
get_time_point, \
1578
duration, \
1579
logger.get_name(), \
1580
__VA_ARGS__); \
1581
} while (0)
1582
1583
// The RCLCPP_ERROR_STREAM macro is surrounded by do { .. } while (0)
1584
// to implement the standard C macro idiom to make the macro safe in all
1585
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1592
#define RCLCPP_ERROR_STREAM(logger, stream_arg) \
1593
do { \
1594
static_assert( \
1595
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1596
typename ::rclcpp::Logger>::value, \
1597
"First argument to logging macros must be an rclcpp::Logger"); \
1598
\
1599
std::stringstream ss; \
1600
ss << stream_arg; \
1601
RCUTILS_LOG_ERROR_NAMED( \
1602
logger.get_name(), \
1603
"%s", ss.str().c_str()); \
1604
} while (0)
1605
1606
// The RCLCPP_ERROR_STREAM_ONCE macro is surrounded by do { .. } while (0)
1607
// to implement the standard C macro idiom to make the macro safe in all
1608
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1616
#define RCLCPP_ERROR_STREAM_ONCE(logger, stream_arg) \
1617
do { \
1618
static_assert( \
1619
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1620
typename ::rclcpp::Logger>::value, \
1621
"First argument to logging macros must be an rclcpp::Logger"); \
1622
\
1623
std::stringstream ss; \
1624
ss << stream_arg; \
1625
RCUTILS_LOG_ERROR_ONCE_NAMED( \
1626
logger.get_name(), \
1627
"%s", ss.str().c_str()); \
1628
} while (0)
1629
1630
// The RCLCPP_ERROR_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
1631
// to implement the standard C macro idiom to make the macro safe in all
1632
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1641
#define RCLCPP_ERROR_STREAM_EXPRESSION(logger, expression, stream_arg) \
1642
do { \
1643
static_assert( \
1644
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1645
typename ::rclcpp::Logger>::value, \
1646
"First argument to logging macros must be an rclcpp::Logger"); \
1647
\
1648
std::stringstream ss; \
1649
ss << stream_arg; \
1650
RCUTILS_LOG_ERROR_EXPRESSION_NAMED( \
1651
expression, \
1652
logger.get_name(), \
1653
"%s", ss.str().c_str()); \
1654
} while (0)
1655
1656
// The RCLCPP_ERROR_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
1657
// to implement the standard C macro idiom to make the macro safe in all
1658
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1667
#define RCLCPP_ERROR_STREAM_FUNCTION(logger, function, stream_arg) \
1668
do { \
1669
static_assert( \
1670
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1671
typename ::rclcpp::Logger>::value, \
1672
"First argument to logging macros must be an rclcpp::Logger"); \
1673
\
1674
std::stringstream ss; \
1675
ss << stream_arg; \
1676
RCUTILS_LOG_ERROR_FUNCTION_NAMED( \
1677
function, \
1678
logger.get_name(), \
1679
"%s", ss.str().c_str()); \
1680
} while (0)
1681
1682
// The RCLCPP_ERROR_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
1683
// to implement the standard C macro idiom to make the macro safe in all
1684
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1692
#define RCLCPP_ERROR_STREAM_SKIPFIRST(logger, stream_arg) \
1693
do { \
1694
static_assert( \
1695
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1696
typename ::rclcpp::Logger>::value, \
1697
"First argument to logging macros must be an rclcpp::Logger"); \
1698
\
1699
std::stringstream ss; \
1700
ss << stream_arg; \
1701
RCUTILS_LOG_ERROR_SKIPFIRST_NAMED( \
1702
logger.get_name(), \
1703
"%s", ss.str().c_str()); \
1704
} while (0)
1705
1706
// The RCLCPP_ERROR_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
1707
// to implement the standard C macro idiom to make the macro safe in all
1708
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1718
#define RCLCPP_ERROR_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
1719
do { \
1720
static_assert( \
1721
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1722
typename ::rclcpp::Logger>::value, \
1723
"First argument to logging macros must be an rclcpp::Logger"); \
1724
\
1725
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1726
try { \
1727
*time_point = c.now().nanoseconds(); \
1728
} catch (...) { \
1729
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1730
"[rclcpp|logging.hpp] RCLCPP_ERROR_STREAM_THROTTLE could not get current time stamp\n"); \
1731
return RCUTILS_RET_ERROR; \
1732
} \
1733
return RCUTILS_RET_OK; \
1734
}; \
1735
\
1736
std::stringstream ss; \
1737
ss << stream_arg; \
1738
RCUTILS_LOG_ERROR_THROTTLE_NAMED( \
1739
get_time_point, \
1740
duration, \
1741
logger.get_name(), \
1742
"%s", ss.str().c_str()); \
1743
} while (0)
1744
1745
// The RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1746
// to implement the standard C macro idiom to make the macro safe in all
1747
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1758
#define RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
1759
do { \
1760
static_assert( \
1761
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1762
typename ::rclcpp::Logger>::value, \
1763
"First argument to logging macros must be an rclcpp::Logger"); \
1764
\
1765
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1766
try { \
1767
*time_point = c.now().nanoseconds(); \
1768
} catch (...) { \
1769
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1770
"[rclcpp|logging.hpp] RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1771
return RCUTILS_RET_ERROR; \
1772
} \
1773
return RCUTILS_RET_OK; \
1774
}; \
1775
\
1776
std::stringstream ss; \
1777
ss << stream_arg; \
1778
RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED( \
1779
get_time_point, \
1780
duration, \
1781
logger.get_name(), \
1782
"%s", ss.str().c_str()); \
1783
} while (0)
1784
1785
#endif
1786
1790
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_FATAL)
1792
// empty logging macros for severity FATAL when being disabled at compile time
1794
#define RCLCPP_FATAL(...)
1795
#define RCLCPP_FATAL_ONCE(...)
1797
#define RCLCPP_FATAL_EXPRESSION(...)
1799
#define RCLCPP_FATAL_FUNCTION(...)
1801
#define RCLCPP_FATAL_SKIPFIRST(...)
1803
#define RCLCPP_FATAL_THROTTLE(...)
1805
#define RCLCPP_FATAL_SKIPFIRST_THROTTLE(...)
1807
#define RCLCPP_FATAL_STREAM(...)
1809
#define RCLCPP_FATAL_STREAM_ONCE(...)
1811
#define RCLCPP_FATAL_STREAM_EXPRESSION(...)
1813
#define RCLCPP_FATAL_STREAM_FUNCTION(...)
1815
#define RCLCPP_FATAL_STREAM_SKIPFIRST(...)
1817
#define RCLCPP_FATAL_STREAM_THROTTLE(...)
1819
#define RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE(...)
1821
1822
#else
1823
// The RCLCPP_FATAL macro is surrounded by do { .. } while (0)
1824
// to implement the standard C macro idiom to make the macro safe in all
1825
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1833
#define RCLCPP_FATAL(logger, ...) \
1834
do { \
1835
static_assert( \
1836
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1837
typename ::rclcpp::Logger>::value, \
1838
"First argument to logging macros must be an rclcpp::Logger"); \
1839
\
1840
RCUTILS_LOG_FATAL_NAMED( \
1841
logger.get_name(), \
1842
__VA_ARGS__); \
1843
} while (0)
1844
1845
// The RCLCPP_FATAL_ONCE macro is surrounded by do { .. } while (0)
1846
// to implement the standard C macro idiom to make the macro safe in all
1847
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1856
#define RCLCPP_FATAL_ONCE(logger, ...) \
1857
do { \
1858
static_assert( \
1859
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1860
typename ::rclcpp::Logger>::value, \
1861
"First argument to logging macros must be an rclcpp::Logger"); \
1862
\
1863
RCUTILS_LOG_FATAL_ONCE_NAMED( \
1864
logger.get_name(), \
1865
__VA_ARGS__); \
1866
} while (0)
1867
1868
// The RCLCPP_FATAL_EXPRESSION macro is surrounded by do { .. } while (0)
1869
// to implement the standard C macro idiom to make the macro safe in all
1870
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1880
#define RCLCPP_FATAL_EXPRESSION(logger, expression, ...) \
1881
do { \
1882
static_assert( \
1883
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1884
typename ::rclcpp::Logger>::value, \
1885
"First argument to logging macros must be an rclcpp::Logger"); \
1886
\
1887
RCUTILS_LOG_FATAL_EXPRESSION_NAMED( \
1888
expression, \
1889
logger.get_name(), \
1890
__VA_ARGS__); \
1891
} while (0)
1892
1893
// The RCLCPP_FATAL_FUNCTION macro is surrounded by do { .. } while (0)
1894
// to implement the standard C macro idiom to make the macro safe in all
1895
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1905
#define RCLCPP_FATAL_FUNCTION(logger, function, ...) \
1906
do { \
1907
static_assert( \
1908
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1909
typename ::rclcpp::Logger>::value, \
1910
"First argument to logging macros must be an rclcpp::Logger"); \
1911
\
1912
RCUTILS_LOG_FATAL_FUNCTION_NAMED( \
1913
function, \
1914
logger.get_name(), \
1915
__VA_ARGS__); \
1916
} while (0)
1917
1918
// The RCLCPP_FATAL_SKIPFIRST macro is surrounded by do { .. } while (0)
1919
// to implement the standard C macro idiom to make the macro safe in all
1920
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1929
#define RCLCPP_FATAL_SKIPFIRST(logger, ...) \
1930
do { \
1931
static_assert( \
1932
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1933
typename ::rclcpp::Logger>::value, \
1934
"First argument to logging macros must be an rclcpp::Logger"); \
1935
\
1936
RCUTILS_LOG_FATAL_SKIPFIRST_NAMED( \
1937
logger.get_name(), \
1938
__VA_ARGS__); \
1939
} while (0)
1940
1941
// The RCLCPP_FATAL_THROTTLE macro is surrounded by do { .. } while (0)
1942
// to implement the standard C macro idiom to make the macro safe in all
1943
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1954
#define RCLCPP_FATAL_THROTTLE(logger, clock, duration, ...) \
1955
do { \
1956
static_assert( \
1957
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1958
typename ::rclcpp::Logger>::value, \
1959
"First argument to logging macros must be an rclcpp::Logger"); \
1960
\
1961
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1962
try { \
1963
*time_point = c.now().nanoseconds(); \
1964
} catch (...) { \
1965
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1966
"[rclcpp|logging.hpp] RCLCPP_FATAL_THROTTLE could not get current time stamp\n"); \
1967
return RCUTILS_RET_ERROR; \
1968
} \
1969
return RCUTILS_RET_OK; \
1970
}; \
1971
\
1972
RCUTILS_LOG_FATAL_THROTTLE_NAMED( \
1973
get_time_point, \
1974
duration, \
1975
logger.get_name(), \
1976
__VA_ARGS__); \
1977
} while (0)
1978
1979
// The RCLCPP_FATAL_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1980
// to implement the standard C macro idiom to make the macro safe in all
1981
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1993
#define RCLCPP_FATAL_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
1994
do { \
1995
static_assert( \
1996
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1997
typename ::rclcpp::Logger>::value, \
1998
"First argument to logging macros must be an rclcpp::Logger"); \
1999
\
2000
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
2001
try { \
2002
*time_point = c.now().nanoseconds(); \
2003
} catch (...) { \
2004
RCUTILS_SAFE_FWRITE_TO_STDERR( \
2005
"[rclcpp|logging.hpp] RCLCPP_FATAL_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
2006
return RCUTILS_RET_ERROR; \
2007
} \
2008
return RCUTILS_RET_OK; \
2009
}; \
2010
\
2011
RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED( \
2012
get_time_point, \
2013
duration, \
2014
logger.get_name(), \
2015
__VA_ARGS__); \
2016
} while (0)
2017
2018
// The RCLCPP_FATAL_STREAM macro is surrounded by do { .. } while (0)
2019
// to implement the standard C macro idiom to make the macro safe in all
2020
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2027
#define RCLCPP_FATAL_STREAM(logger, stream_arg) \
2028
do { \
2029
static_assert( \
2030
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2031
typename ::rclcpp::Logger>::value, \
2032
"First argument to logging macros must be an rclcpp::Logger"); \
2033
\
2034
std::stringstream ss; \
2035
ss << stream_arg; \
2036
RCUTILS_LOG_FATAL_NAMED( \
2037
logger.get_name(), \
2038
"%s", ss.str().c_str()); \
2039
} while (0)
2040
2041
// The RCLCPP_FATAL_STREAM_ONCE macro is surrounded by do { .. } while (0)
2042
// to implement the standard C macro idiom to make the macro safe in all
2043
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2051
#define RCLCPP_FATAL_STREAM_ONCE(logger, stream_arg) \
2052
do { \
2053
static_assert( \
2054
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2055
typename ::rclcpp::Logger>::value, \
2056
"First argument to logging macros must be an rclcpp::Logger"); \
2057
\
2058
std::stringstream ss; \
2059
ss << stream_arg; \
2060
RCUTILS_LOG_FATAL_ONCE_NAMED( \
2061
logger.get_name(), \
2062
"%s", ss.str().c_str()); \
2063
} while (0)
2064
2065
// The RCLCPP_FATAL_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
2066
// to implement the standard C macro idiom to make the macro safe in all
2067
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2076
#define RCLCPP_FATAL_STREAM_EXPRESSION(logger, expression, stream_arg) \
2077
do { \
2078
static_assert( \
2079
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2080
typename ::rclcpp::Logger>::value, \
2081
"First argument to logging macros must be an rclcpp::Logger"); \
2082
\
2083
std::stringstream ss; \
2084
ss << stream_arg; \
2085
RCUTILS_LOG_FATAL_EXPRESSION_NAMED( \
2086
expression, \
2087
logger.get_name(), \
2088
"%s", ss.str().c_str()); \
2089
} while (0)
2090
2091
// The RCLCPP_FATAL_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
2092
// to implement the standard C macro idiom to make the macro safe in all
2093
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2102
#define RCLCPP_FATAL_STREAM_FUNCTION(logger, function, stream_arg) \
2103
do { \
2104
static_assert( \
2105
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2106
typename ::rclcpp::Logger>::value, \
2107
"First argument to logging macros must be an rclcpp::Logger"); \
2108
\
2109
std::stringstream ss; \
2110
ss << stream_arg; \
2111
RCUTILS_LOG_FATAL_FUNCTION_NAMED( \
2112
function, \
2113
logger.get_name(), \
2114
"%s", ss.str().c_str()); \
2115
} while (0)
2116
2117
// The RCLCPP_FATAL_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
2118
// to implement the standard C macro idiom to make the macro safe in all
2119
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2127
#define RCLCPP_FATAL_STREAM_SKIPFIRST(logger, stream_arg) \
2128
do { \
2129
static_assert( \
2130
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2131
typename ::rclcpp::Logger>::value, \
2132
"First argument to logging macros must be an rclcpp::Logger"); \
2133
\
2134
std::stringstream ss; \
2135
ss << stream_arg; \
2136
RCUTILS_LOG_FATAL_SKIPFIRST_NAMED( \
2137
logger.get_name(), \
2138
"%s", ss.str().c_str()); \
2139
} while (0)
2140
2141
// The RCLCPP_FATAL_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
2142
// to implement the standard C macro idiom to make the macro safe in all
2143
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2153
#define RCLCPP_FATAL_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
2154
do { \
2155
static_assert( \
2156
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2157
typename ::rclcpp::Logger>::value, \
2158
"First argument to logging macros must be an rclcpp::Logger"); \
2159
\
2160
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
2161
try { \
2162
*time_point = c.now().nanoseconds(); \
2163
} catch (...) { \
2164
RCUTILS_SAFE_FWRITE_TO_STDERR( \
2165
"[rclcpp|logging.hpp] RCLCPP_FATAL_STREAM_THROTTLE could not get current time stamp\n"); \
2166
return RCUTILS_RET_ERROR; \
2167
} \
2168
return RCUTILS_RET_OK; \
2169
}; \
2170
\
2171
std::stringstream ss; \
2172
ss << stream_arg; \
2173
RCUTILS_LOG_FATAL_THROTTLE_NAMED( \
2174
get_time_point, \
2175
duration, \
2176
logger.get_name(), \
2177
"%s", ss.str().c_str()); \
2178
} while (0)
2179
2180
// The RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
2181
// to implement the standard C macro idiom to make the macro safe in all
2182
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2193
#define RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
2194
do { \
2195
static_assert( \
2196
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2197
typename ::rclcpp::Logger>::value, \
2198
"First argument to logging macros must be an rclcpp::Logger"); \
2199
\
2200
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
2201
try { \
2202
*time_point = c.now().nanoseconds(); \
2203
} catch (...) { \
2204
RCUTILS_SAFE_FWRITE_TO_STDERR( \
2205
"[rclcpp|logging.hpp] RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
2206
return RCUTILS_RET_ERROR; \
2207
} \
2208
return RCUTILS_RET_OK; \
2209
}; \
2210
\
2211
std::stringstream ss; \
2212
ss << stream_arg; \
2213
RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED( \
2214
get_time_point, \
2215
duration, \
2216
logger.get_name(), \
2217
"%s", ss.str().c_str()); \
2218
} while (0)
2219
2220
#endif
2221
2223
2224
#endif // RCLCPP__LOGGING_HPP_
logging_macros.h
logger.hpp
utilities.hpp
Generated by
1.8.17