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
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
103
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
104
} while (0)
105
106
// The RCLCPP_DEBUG_ONCE macro is surrounded by do { .. } while (0)
107
// to implement the standard C macro idiom to make the macro safe in all
108
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
117
#define RCLCPP_DEBUG_ONCE(logger, ...) \
118
do { \
119
static_assert( \
120
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
121
typename ::rclcpp::Logger>::value, \
122
"First argument to logging macros must be an rclcpp::Logger"); \
123
\
124
RCUTILS_LOG_DEBUG_ONCE_NAMED( \
125
logger.get_name(), \
126
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
127
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
128
} while (0)
129
130
// The RCLCPP_DEBUG_EXPRESSION macro is surrounded by do { .. } while (0)
131
// to implement the standard C macro idiom to make the macro safe in all
132
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
142
#define RCLCPP_DEBUG_EXPRESSION(logger, expression, ...) \
143
do { \
144
static_assert( \
145
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
146
typename ::rclcpp::Logger>::value, \
147
"First argument to logging macros must be an rclcpp::Logger"); \
148
\
149
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED( \
150
expression, \
151
logger.get_name(), \
152
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
153
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
154
} while (0)
155
156
// The RCLCPP_DEBUG_FUNCTION macro is surrounded by do { .. } while (0)
157
// to implement the standard C macro idiom to make the macro safe in all
158
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
168
#define RCLCPP_DEBUG_FUNCTION(logger, function, ...) \
169
do { \
170
static_assert( \
171
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
172
typename ::rclcpp::Logger>::value, \
173
"First argument to logging macros must be an rclcpp::Logger"); \
174
\
175
RCUTILS_LOG_DEBUG_FUNCTION_NAMED( \
176
function, \
177
logger.get_name(), \
178
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
179
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
180
} while (0)
181
182
// The RCLCPP_DEBUG_SKIPFIRST macro is surrounded by do { .. } while (0)
183
// to implement the standard C macro idiom to make the macro safe in all
184
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
193
#define RCLCPP_DEBUG_SKIPFIRST(logger, ...) \
194
do { \
195
static_assert( \
196
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
197
typename ::rclcpp::Logger>::value, \
198
"First argument to logging macros must be an rclcpp::Logger"); \
199
\
200
RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED( \
201
logger.get_name(), \
202
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
203
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
204
} while (0)
205
206
// The RCLCPP_DEBUG_THROTTLE macro is surrounded by do { .. } while (0)
207
// to implement the standard C macro idiom to make the macro safe in all
208
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
219
#define RCLCPP_DEBUG_THROTTLE(logger, clock, duration, ...) \
220
do { \
221
static_assert( \
222
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
223
typename ::rclcpp::Logger>::value, \
224
"First argument to logging macros must be an rclcpp::Logger"); \
225
\
226
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
227
try { \
228
*time_point = c.now().nanoseconds(); \
229
} catch (...) { \
230
RCUTILS_SAFE_FWRITE_TO_STDERR( \
231
"[rclcpp|logging.hpp] RCLCPP_DEBUG_THROTTLE could not get current time stamp\n"); \
232
return RCUTILS_RET_ERROR; \
233
} \
234
return RCUTILS_RET_OK; \
235
}; \
236
\
237
RCUTILS_LOG_DEBUG_THROTTLE_NAMED( \
238
get_time_point, \
239
duration, \
240
logger.get_name(), \
241
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
242
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
243
} while (0)
244
245
// The RCLCPP_DEBUG_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
246
// to implement the standard C macro idiom to make the macro safe in all
247
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
259
#define RCLCPP_DEBUG_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
260
do { \
261
static_assert( \
262
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
263
typename ::rclcpp::Logger>::value, \
264
"First argument to logging macros must be an rclcpp::Logger"); \
265
\
266
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
267
try { \
268
*time_point = c.now().nanoseconds(); \
269
} catch (...) { \
270
RCUTILS_SAFE_FWRITE_TO_STDERR( \
271
"[rclcpp|logging.hpp] RCLCPP_DEBUG_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
272
return RCUTILS_RET_ERROR; \
273
} \
274
return RCUTILS_RET_OK; \
275
}; \
276
\
277
RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED( \
278
get_time_point, \
279
duration, \
280
logger.get_name(), \
281
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
282
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
283
} while (0)
284
285
// The RCLCPP_DEBUG_STREAM macro is surrounded by do { .. } while (0)
286
// to implement the standard C macro idiom to make the macro safe in all
287
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
294
#define RCLCPP_DEBUG_STREAM(logger, stream_arg) \
295
do { \
296
static_assert( \
297
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
298
typename ::rclcpp::Logger>::value, \
299
"First argument to logging macros must be an rclcpp::Logger"); \
300
\
301
std::stringstream ss; \
302
ss << stream_arg; \
303
RCUTILS_LOG_DEBUG_NAMED( \
304
logger.get_name(), \
305
"%s", rclcpp::get_c_string(ss.str())); \
306
} while (0)
307
308
// The RCLCPP_DEBUG_STREAM_ONCE macro is surrounded by do { .. } while (0)
309
// to implement the standard C macro idiom to make the macro safe in all
310
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
318
#define RCLCPP_DEBUG_STREAM_ONCE(logger, stream_arg) \
319
do { \
320
static_assert( \
321
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
322
typename ::rclcpp::Logger>::value, \
323
"First argument to logging macros must be an rclcpp::Logger"); \
324
\
325
std::stringstream ss; \
326
ss << stream_arg; \
327
RCUTILS_LOG_DEBUG_ONCE_NAMED( \
328
logger.get_name(), \
329
"%s", rclcpp::get_c_string(ss.str())); \
330
} while (0)
331
332
// The RCLCPP_DEBUG_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
333
// to implement the standard C macro idiom to make the macro safe in all
334
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
343
#define RCLCPP_DEBUG_STREAM_EXPRESSION(logger, expression, stream_arg) \
344
do { \
345
static_assert( \
346
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
347
typename ::rclcpp::Logger>::value, \
348
"First argument to logging macros must be an rclcpp::Logger"); \
349
\
350
std::stringstream ss; \
351
ss << stream_arg; \
352
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED( \
353
expression, \
354
logger.get_name(), \
355
"%s", rclcpp::get_c_string(ss.str())); \
356
} while (0)
357
358
// The RCLCPP_DEBUG_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
359
// to implement the standard C macro idiom to make the macro safe in all
360
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
369
#define RCLCPP_DEBUG_STREAM_FUNCTION(logger, function, stream_arg) \
370
do { \
371
static_assert( \
372
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
373
typename ::rclcpp::Logger>::value, \
374
"First argument to logging macros must be an rclcpp::Logger"); \
375
\
376
std::stringstream ss; \
377
ss << stream_arg; \
378
RCUTILS_LOG_DEBUG_FUNCTION_NAMED( \
379
function, \
380
logger.get_name(), \
381
"%s", rclcpp::get_c_string(ss.str())); \
382
} while (0)
383
384
// The RCLCPP_DEBUG_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
385
// to implement the standard C macro idiom to make the macro safe in all
386
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
394
#define RCLCPP_DEBUG_STREAM_SKIPFIRST(logger, stream_arg) \
395
do { \
396
static_assert( \
397
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
398
typename ::rclcpp::Logger>::value, \
399
"First argument to logging macros must be an rclcpp::Logger"); \
400
\
401
std::stringstream ss; \
402
ss << stream_arg; \
403
RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED( \
404
logger.get_name(), \
405
"%s", rclcpp::get_c_string(ss.str())); \
406
} while (0)
407
408
// The RCLCPP_DEBUG_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
409
// to implement the standard C macro idiom to make the macro safe in all
410
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
420
#define RCLCPP_DEBUG_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
421
do { \
422
static_assert( \
423
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
424
typename ::rclcpp::Logger>::value, \
425
"First argument to logging macros must be an rclcpp::Logger"); \
426
\
427
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
428
try { \
429
*time_point = c.now().nanoseconds(); \
430
} catch (...) { \
431
RCUTILS_SAFE_FWRITE_TO_STDERR( \
432
"[rclcpp|logging.hpp] RCLCPP_DEBUG_STREAM_THROTTLE could not get current time stamp\n"); \
433
return RCUTILS_RET_ERROR; \
434
} \
435
return RCUTILS_RET_OK; \
436
}; \
437
\
438
std::stringstream ss; \
439
ss << stream_arg; \
440
RCUTILS_LOG_DEBUG_THROTTLE_NAMED( \
441
get_time_point, \
442
duration, \
443
logger.get_name(), \
444
"%s", rclcpp::get_c_string(ss.str())); \
445
} while (0)
446
447
// The RCLCPP_DEBUG_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
448
// to implement the standard C macro idiom to make the macro safe in all
449
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
460
#define RCLCPP_DEBUG_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
461
do { \
462
static_assert( \
463
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
464
typename ::rclcpp::Logger>::value, \
465
"First argument to logging macros must be an rclcpp::Logger"); \
466
\
467
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
468
try { \
469
*time_point = c.now().nanoseconds(); \
470
} catch (...) { \
471
RCUTILS_SAFE_FWRITE_TO_STDERR( \
472
"[rclcpp|logging.hpp] RCLCPP_DEBUG_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
473
return RCUTILS_RET_ERROR; \
474
} \
475
return RCUTILS_RET_OK; \
476
}; \
477
\
478
std::stringstream ss; \
479
ss << stream_arg; \
480
RCUTILS_LOG_DEBUG_SKIPFIRST_THROTTLE_NAMED( \
481
get_time_point, \
482
duration, \
483
logger.get_name(), \
484
"%s", rclcpp::get_c_string(ss.str())); \
485
} while (0)
486
487
#endif
488
492
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_INFO)
494
// empty logging macros for severity INFO when being disabled at compile time
496
#define RCLCPP_INFO(...)
497
#define RCLCPP_INFO_ONCE(...)
499
#define RCLCPP_INFO_EXPRESSION(...)
501
#define RCLCPP_INFO_FUNCTION(...)
503
#define RCLCPP_INFO_SKIPFIRST(...)
505
#define RCLCPP_INFO_THROTTLE(...)
507
#define RCLCPP_INFO_SKIPFIRST_THROTTLE(...)
509
#define RCLCPP_INFO_STREAM(...)
511
#define RCLCPP_INFO_STREAM_ONCE(...)
513
#define RCLCPP_INFO_STREAM_EXPRESSION(...)
515
#define RCLCPP_INFO_STREAM_FUNCTION(...)
517
#define RCLCPP_INFO_STREAM_SKIPFIRST(...)
519
#define RCLCPP_INFO_STREAM_THROTTLE(...)
521
#define RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE(...)
523
524
#else
525
// The RCLCPP_INFO macro is surrounded by do { .. } while (0)
526
// to implement the standard C macro idiom to make the macro safe in all
527
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
535
#define RCLCPP_INFO(logger, ...) \
536
do { \
537
static_assert( \
538
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
539
typename ::rclcpp::Logger>::value, \
540
"First argument to logging macros must be an rclcpp::Logger"); \
541
\
542
RCUTILS_LOG_INFO_NAMED( \
543
logger.get_name(), \
544
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
545
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
546
} while (0)
547
548
// The RCLCPP_INFO_ONCE macro is surrounded by do { .. } while (0)
549
// to implement the standard C macro idiom to make the macro safe in all
550
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
559
#define RCLCPP_INFO_ONCE(logger, ...) \
560
do { \
561
static_assert( \
562
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
563
typename ::rclcpp::Logger>::value, \
564
"First argument to logging macros must be an rclcpp::Logger"); \
565
\
566
RCUTILS_LOG_INFO_ONCE_NAMED( \
567
logger.get_name(), \
568
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
569
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
570
} while (0)
571
572
// The RCLCPP_INFO_EXPRESSION macro is surrounded by do { .. } while (0)
573
// to implement the standard C macro idiom to make the macro safe in all
574
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
584
#define RCLCPP_INFO_EXPRESSION(logger, expression, ...) \
585
do { \
586
static_assert( \
587
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
588
typename ::rclcpp::Logger>::value, \
589
"First argument to logging macros must be an rclcpp::Logger"); \
590
\
591
RCUTILS_LOG_INFO_EXPRESSION_NAMED( \
592
expression, \
593
logger.get_name(), \
594
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
595
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
596
} while (0)
597
598
// The RCLCPP_INFO_FUNCTION macro is surrounded by do { .. } while (0)
599
// to implement the standard C macro idiom to make the macro safe in all
600
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
610
#define RCLCPP_INFO_FUNCTION(logger, function, ...) \
611
do { \
612
static_assert( \
613
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
614
typename ::rclcpp::Logger>::value, \
615
"First argument to logging macros must be an rclcpp::Logger"); \
616
\
617
RCUTILS_LOG_INFO_FUNCTION_NAMED( \
618
function, \
619
logger.get_name(), \
620
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
621
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
622
} while (0)
623
624
// The RCLCPP_INFO_SKIPFIRST macro is surrounded by do { .. } while (0)
625
// to implement the standard C macro idiom to make the macro safe in all
626
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
635
#define RCLCPP_INFO_SKIPFIRST(logger, ...) \
636
do { \
637
static_assert( \
638
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
639
typename ::rclcpp::Logger>::value, \
640
"First argument to logging macros must be an rclcpp::Logger"); \
641
\
642
RCUTILS_LOG_INFO_SKIPFIRST_NAMED( \
643
logger.get_name(), \
644
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
645
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
646
} while (0)
647
648
// The RCLCPP_INFO_THROTTLE macro is surrounded by do { .. } while (0)
649
// to implement the standard C macro idiom to make the macro safe in all
650
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
661
#define RCLCPP_INFO_THROTTLE(logger, clock, duration, ...) \
662
do { \
663
static_assert( \
664
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
665
typename ::rclcpp::Logger>::value, \
666
"First argument to logging macros must be an rclcpp::Logger"); \
667
\
668
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
669
try { \
670
*time_point = c.now().nanoseconds(); \
671
} catch (...) { \
672
RCUTILS_SAFE_FWRITE_TO_STDERR( \
673
"[rclcpp|logging.hpp] RCLCPP_INFO_THROTTLE could not get current time stamp\n"); \
674
return RCUTILS_RET_ERROR; \
675
} \
676
return RCUTILS_RET_OK; \
677
}; \
678
\
679
RCUTILS_LOG_INFO_THROTTLE_NAMED( \
680
get_time_point, \
681
duration, \
682
logger.get_name(), \
683
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
684
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
685
} while (0)
686
687
// The RCLCPP_INFO_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
688
// to implement the standard C macro idiom to make the macro safe in all
689
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
701
#define RCLCPP_INFO_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
702
do { \
703
static_assert( \
704
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
705
typename ::rclcpp::Logger>::value, \
706
"First argument to logging macros must be an rclcpp::Logger"); \
707
\
708
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
709
try { \
710
*time_point = c.now().nanoseconds(); \
711
} catch (...) { \
712
RCUTILS_SAFE_FWRITE_TO_STDERR( \
713
"[rclcpp|logging.hpp] RCLCPP_INFO_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
714
return RCUTILS_RET_ERROR; \
715
} \
716
return RCUTILS_RET_OK; \
717
}; \
718
\
719
RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED( \
720
get_time_point, \
721
duration, \
722
logger.get_name(), \
723
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
724
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
725
} while (0)
726
727
// The RCLCPP_INFO_STREAM macro is surrounded by do { .. } while (0)
728
// to implement the standard C macro idiom to make the macro safe in all
729
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
736
#define RCLCPP_INFO_STREAM(logger, stream_arg) \
737
do { \
738
static_assert( \
739
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
740
typename ::rclcpp::Logger>::value, \
741
"First argument to logging macros must be an rclcpp::Logger"); \
742
\
743
std::stringstream ss; \
744
ss << stream_arg; \
745
RCUTILS_LOG_INFO_NAMED( \
746
logger.get_name(), \
747
"%s", rclcpp::get_c_string(ss.str())); \
748
} while (0)
749
750
// The RCLCPP_INFO_STREAM_ONCE macro is surrounded by do { .. } while (0)
751
// to implement the standard C macro idiom to make the macro safe in all
752
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
760
#define RCLCPP_INFO_STREAM_ONCE(logger, stream_arg) \
761
do { \
762
static_assert( \
763
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
764
typename ::rclcpp::Logger>::value, \
765
"First argument to logging macros must be an rclcpp::Logger"); \
766
\
767
std::stringstream ss; \
768
ss << stream_arg; \
769
RCUTILS_LOG_INFO_ONCE_NAMED( \
770
logger.get_name(), \
771
"%s", rclcpp::get_c_string(ss.str())); \
772
} while (0)
773
774
// The RCLCPP_INFO_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
775
// to implement the standard C macro idiom to make the macro safe in all
776
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
785
#define RCLCPP_INFO_STREAM_EXPRESSION(logger, expression, stream_arg) \
786
do { \
787
static_assert( \
788
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
789
typename ::rclcpp::Logger>::value, \
790
"First argument to logging macros must be an rclcpp::Logger"); \
791
\
792
std::stringstream ss; \
793
ss << stream_arg; \
794
RCUTILS_LOG_INFO_EXPRESSION_NAMED( \
795
expression, \
796
logger.get_name(), \
797
"%s", rclcpp::get_c_string(ss.str())); \
798
} while (0)
799
800
// The RCLCPP_INFO_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
801
// to implement the standard C macro idiom to make the macro safe in all
802
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
811
#define RCLCPP_INFO_STREAM_FUNCTION(logger, function, stream_arg) \
812
do { \
813
static_assert( \
814
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
815
typename ::rclcpp::Logger>::value, \
816
"First argument to logging macros must be an rclcpp::Logger"); \
817
\
818
std::stringstream ss; \
819
ss << stream_arg; \
820
RCUTILS_LOG_INFO_FUNCTION_NAMED( \
821
function, \
822
logger.get_name(), \
823
"%s", rclcpp::get_c_string(ss.str())); \
824
} while (0)
825
826
// The RCLCPP_INFO_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
827
// to implement the standard C macro idiom to make the macro safe in all
828
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
836
#define RCLCPP_INFO_STREAM_SKIPFIRST(logger, stream_arg) \
837
do { \
838
static_assert( \
839
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
840
typename ::rclcpp::Logger>::value, \
841
"First argument to logging macros must be an rclcpp::Logger"); \
842
\
843
std::stringstream ss; \
844
ss << stream_arg; \
845
RCUTILS_LOG_INFO_SKIPFIRST_NAMED( \
846
logger.get_name(), \
847
"%s", rclcpp::get_c_string(ss.str())); \
848
} while (0)
849
850
// The RCLCPP_INFO_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
851
// to implement the standard C macro idiom to make the macro safe in all
852
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
862
#define RCLCPP_INFO_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
863
do { \
864
static_assert( \
865
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
866
typename ::rclcpp::Logger>::value, \
867
"First argument to logging macros must be an rclcpp::Logger"); \
868
\
869
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
870
try { \
871
*time_point = c.now().nanoseconds(); \
872
} catch (...) { \
873
RCUTILS_SAFE_FWRITE_TO_STDERR( \
874
"[rclcpp|logging.hpp] RCLCPP_INFO_STREAM_THROTTLE could not get current time stamp\n"); \
875
return RCUTILS_RET_ERROR; \
876
} \
877
return RCUTILS_RET_OK; \
878
}; \
879
\
880
std::stringstream ss; \
881
ss << stream_arg; \
882
RCUTILS_LOG_INFO_THROTTLE_NAMED( \
883
get_time_point, \
884
duration, \
885
logger.get_name(), \
886
"%s", rclcpp::get_c_string(ss.str())); \
887
} while (0)
888
889
// The RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
890
// to implement the standard C macro idiom to make the macro safe in all
891
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
902
#define RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
903
do { \
904
static_assert( \
905
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
906
typename ::rclcpp::Logger>::value, \
907
"First argument to logging macros must be an rclcpp::Logger"); \
908
\
909
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
910
try { \
911
*time_point = c.now().nanoseconds(); \
912
} catch (...) { \
913
RCUTILS_SAFE_FWRITE_TO_STDERR( \
914
"[rclcpp|logging.hpp] RCLCPP_INFO_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
915
return RCUTILS_RET_ERROR; \
916
} \
917
return RCUTILS_RET_OK; \
918
}; \
919
\
920
std::stringstream ss; \
921
ss << stream_arg; \
922
RCUTILS_LOG_INFO_SKIPFIRST_THROTTLE_NAMED( \
923
get_time_point, \
924
duration, \
925
logger.get_name(), \
926
"%s", rclcpp::get_c_string(ss.str())); \
927
} while (0)
928
929
#endif
930
934
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_WARN)
936
// empty logging macros for severity WARN when being disabled at compile time
938
#define RCLCPP_WARN(...)
939
#define RCLCPP_WARN_ONCE(...)
941
#define RCLCPP_WARN_EXPRESSION(...)
943
#define RCLCPP_WARN_FUNCTION(...)
945
#define RCLCPP_WARN_SKIPFIRST(...)
947
#define RCLCPP_WARN_THROTTLE(...)
949
#define RCLCPP_WARN_SKIPFIRST_THROTTLE(...)
951
#define RCLCPP_WARN_STREAM(...)
953
#define RCLCPP_WARN_STREAM_ONCE(...)
955
#define RCLCPP_WARN_STREAM_EXPRESSION(...)
957
#define RCLCPP_WARN_STREAM_FUNCTION(...)
959
#define RCLCPP_WARN_STREAM_SKIPFIRST(...)
961
#define RCLCPP_WARN_STREAM_THROTTLE(...)
963
#define RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE(...)
965
966
#else
967
// The RCLCPP_WARN macro is surrounded by do { .. } while (0)
968
// to implement the standard C macro idiom to make the macro safe in all
969
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
977
#define RCLCPP_WARN(logger, ...) \
978
do { \
979
static_assert( \
980
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
981
typename ::rclcpp::Logger>::value, \
982
"First argument to logging macros must be an rclcpp::Logger"); \
983
\
984
RCUTILS_LOG_WARN_NAMED( \
985
logger.get_name(), \
986
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
987
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
988
} while (0)
989
990
// The RCLCPP_WARN_ONCE macro is surrounded by do { .. } while (0)
991
// to implement the standard C macro idiom to make the macro safe in all
992
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1001
#define RCLCPP_WARN_ONCE(logger, ...) \
1002
do { \
1003
static_assert( \
1004
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1005
typename ::rclcpp::Logger>::value, \
1006
"First argument to logging macros must be an rclcpp::Logger"); \
1007
\
1008
RCUTILS_LOG_WARN_ONCE_NAMED( \
1009
logger.get_name(), \
1010
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1011
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1012
} while (0)
1013
1014
// The RCLCPP_WARN_EXPRESSION macro is surrounded by do { .. } while (0)
1015
// to implement the standard C macro idiom to make the macro safe in all
1016
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1026
#define RCLCPP_WARN_EXPRESSION(logger, expression, ...) \
1027
do { \
1028
static_assert( \
1029
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1030
typename ::rclcpp::Logger>::value, \
1031
"First argument to logging macros must be an rclcpp::Logger"); \
1032
\
1033
RCUTILS_LOG_WARN_EXPRESSION_NAMED( \
1034
expression, \
1035
logger.get_name(), \
1036
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1037
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1038
} while (0)
1039
1040
// The RCLCPP_WARN_FUNCTION macro is surrounded by do { .. } while (0)
1041
// to implement the standard C macro idiom to make the macro safe in all
1042
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1052
#define RCLCPP_WARN_FUNCTION(logger, function, ...) \
1053
do { \
1054
static_assert( \
1055
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1056
typename ::rclcpp::Logger>::value, \
1057
"First argument to logging macros must be an rclcpp::Logger"); \
1058
\
1059
RCUTILS_LOG_WARN_FUNCTION_NAMED( \
1060
function, \
1061
logger.get_name(), \
1062
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1063
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1064
} while (0)
1065
1066
// The RCLCPP_WARN_SKIPFIRST macro is surrounded by do { .. } while (0)
1067
// to implement the standard C macro idiom to make the macro safe in all
1068
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1077
#define RCLCPP_WARN_SKIPFIRST(logger, ...) \
1078
do { \
1079
static_assert( \
1080
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1081
typename ::rclcpp::Logger>::value, \
1082
"First argument to logging macros must be an rclcpp::Logger"); \
1083
\
1084
RCUTILS_LOG_WARN_SKIPFIRST_NAMED( \
1085
logger.get_name(), \
1086
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1087
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1088
} while (0)
1089
1090
// The RCLCPP_WARN_THROTTLE macro is surrounded by do { .. } while (0)
1091
// to implement the standard C macro idiom to make the macro safe in all
1092
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1103
#define RCLCPP_WARN_THROTTLE(logger, clock, duration, ...) \
1104
do { \
1105
static_assert( \
1106
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1107
typename ::rclcpp::Logger>::value, \
1108
"First argument to logging macros must be an rclcpp::Logger"); \
1109
\
1110
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1111
try { \
1112
*time_point = c.now().nanoseconds(); \
1113
} catch (...) { \
1114
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1115
"[rclcpp|logging.hpp] RCLCPP_WARN_THROTTLE could not get current time stamp\n"); \
1116
return RCUTILS_RET_ERROR; \
1117
} \
1118
return RCUTILS_RET_OK; \
1119
}; \
1120
\
1121
RCUTILS_LOG_WARN_THROTTLE_NAMED( \
1122
get_time_point, \
1123
duration, \
1124
logger.get_name(), \
1125
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1126
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1127
} while (0)
1128
1129
// The RCLCPP_WARN_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1130
// to implement the standard C macro idiom to make the macro safe in all
1131
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1143
#define RCLCPP_WARN_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
1144
do { \
1145
static_assert( \
1146
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1147
typename ::rclcpp::Logger>::value, \
1148
"First argument to logging macros must be an rclcpp::Logger"); \
1149
\
1150
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1151
try { \
1152
*time_point = c.now().nanoseconds(); \
1153
} catch (...) { \
1154
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1155
"[rclcpp|logging.hpp] RCLCPP_WARN_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1156
return RCUTILS_RET_ERROR; \
1157
} \
1158
return RCUTILS_RET_OK; \
1159
}; \
1160
\
1161
RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED( \
1162
get_time_point, \
1163
duration, \
1164
logger.get_name(), \
1165
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1166
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1167
} while (0)
1168
1169
// The RCLCPP_WARN_STREAM macro is surrounded by do { .. } while (0)
1170
// to implement the standard C macro idiom to make the macro safe in all
1171
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1178
#define RCLCPP_WARN_STREAM(logger, stream_arg) \
1179
do { \
1180
static_assert( \
1181
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1182
typename ::rclcpp::Logger>::value, \
1183
"First argument to logging macros must be an rclcpp::Logger"); \
1184
\
1185
std::stringstream ss; \
1186
ss << stream_arg; \
1187
RCUTILS_LOG_WARN_NAMED( \
1188
logger.get_name(), \
1189
"%s", rclcpp::get_c_string(ss.str())); \
1190
} while (0)
1191
1192
// The RCLCPP_WARN_STREAM_ONCE macro is surrounded by do { .. } while (0)
1193
// to implement the standard C macro idiom to make the macro safe in all
1194
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1202
#define RCLCPP_WARN_STREAM_ONCE(logger, stream_arg) \
1203
do { \
1204
static_assert( \
1205
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1206
typename ::rclcpp::Logger>::value, \
1207
"First argument to logging macros must be an rclcpp::Logger"); \
1208
\
1209
std::stringstream ss; \
1210
ss << stream_arg; \
1211
RCUTILS_LOG_WARN_ONCE_NAMED( \
1212
logger.get_name(), \
1213
"%s", rclcpp::get_c_string(ss.str())); \
1214
} while (0)
1215
1216
// The RCLCPP_WARN_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
1217
// to implement the standard C macro idiom to make the macro safe in all
1218
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1227
#define RCLCPP_WARN_STREAM_EXPRESSION(logger, expression, stream_arg) \
1228
do { \
1229
static_assert( \
1230
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1231
typename ::rclcpp::Logger>::value, \
1232
"First argument to logging macros must be an rclcpp::Logger"); \
1233
\
1234
std::stringstream ss; \
1235
ss << stream_arg; \
1236
RCUTILS_LOG_WARN_EXPRESSION_NAMED( \
1237
expression, \
1238
logger.get_name(), \
1239
"%s", rclcpp::get_c_string(ss.str())); \
1240
} while (0)
1241
1242
// The RCLCPP_WARN_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
1243
// to implement the standard C macro idiom to make the macro safe in all
1244
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1253
#define RCLCPP_WARN_STREAM_FUNCTION(logger, function, stream_arg) \
1254
do { \
1255
static_assert( \
1256
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1257
typename ::rclcpp::Logger>::value, \
1258
"First argument to logging macros must be an rclcpp::Logger"); \
1259
\
1260
std::stringstream ss; \
1261
ss << stream_arg; \
1262
RCUTILS_LOG_WARN_FUNCTION_NAMED( \
1263
function, \
1264
logger.get_name(), \
1265
"%s", rclcpp::get_c_string(ss.str())); \
1266
} while (0)
1267
1268
// The RCLCPP_WARN_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
1269
// to implement the standard C macro idiom to make the macro safe in all
1270
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1278
#define RCLCPP_WARN_STREAM_SKIPFIRST(logger, stream_arg) \
1279
do { \
1280
static_assert( \
1281
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1282
typename ::rclcpp::Logger>::value, \
1283
"First argument to logging macros must be an rclcpp::Logger"); \
1284
\
1285
std::stringstream ss; \
1286
ss << stream_arg; \
1287
RCUTILS_LOG_WARN_SKIPFIRST_NAMED( \
1288
logger.get_name(), \
1289
"%s", rclcpp::get_c_string(ss.str())); \
1290
} while (0)
1291
1292
// The RCLCPP_WARN_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
1293
// to implement the standard C macro idiom to make the macro safe in all
1294
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1304
#define RCLCPP_WARN_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
1305
do { \
1306
static_assert( \
1307
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1308
typename ::rclcpp::Logger>::value, \
1309
"First argument to logging macros must be an rclcpp::Logger"); \
1310
\
1311
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1312
try { \
1313
*time_point = c.now().nanoseconds(); \
1314
} catch (...) { \
1315
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1316
"[rclcpp|logging.hpp] RCLCPP_WARN_STREAM_THROTTLE could not get current time stamp\n"); \
1317
return RCUTILS_RET_ERROR; \
1318
} \
1319
return RCUTILS_RET_OK; \
1320
}; \
1321
\
1322
std::stringstream ss; \
1323
ss << stream_arg; \
1324
RCUTILS_LOG_WARN_THROTTLE_NAMED( \
1325
get_time_point, \
1326
duration, \
1327
logger.get_name(), \
1328
"%s", rclcpp::get_c_string(ss.str())); \
1329
} while (0)
1330
1331
// The RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1332
// to implement the standard C macro idiom to make the macro safe in all
1333
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1344
#define RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
1345
do { \
1346
static_assert( \
1347
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1348
typename ::rclcpp::Logger>::value, \
1349
"First argument to logging macros must be an rclcpp::Logger"); \
1350
\
1351
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1352
try { \
1353
*time_point = c.now().nanoseconds(); \
1354
} catch (...) { \
1355
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1356
"[rclcpp|logging.hpp] RCLCPP_WARN_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1357
return RCUTILS_RET_ERROR; \
1358
} \
1359
return RCUTILS_RET_OK; \
1360
}; \
1361
\
1362
std::stringstream ss; \
1363
ss << stream_arg; \
1364
RCUTILS_LOG_WARN_SKIPFIRST_THROTTLE_NAMED( \
1365
get_time_point, \
1366
duration, \
1367
logger.get_name(), \
1368
"%s", rclcpp::get_c_string(ss.str())); \
1369
} while (0)
1370
1371
#endif
1372
1376
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_ERROR)
1378
// empty logging macros for severity ERROR when being disabled at compile time
1380
#define RCLCPP_ERROR(...)
1381
#define RCLCPP_ERROR_ONCE(...)
1383
#define RCLCPP_ERROR_EXPRESSION(...)
1385
#define RCLCPP_ERROR_FUNCTION(...)
1387
#define RCLCPP_ERROR_SKIPFIRST(...)
1389
#define RCLCPP_ERROR_THROTTLE(...)
1391
#define RCLCPP_ERROR_SKIPFIRST_THROTTLE(...)
1393
#define RCLCPP_ERROR_STREAM(...)
1395
#define RCLCPP_ERROR_STREAM_ONCE(...)
1397
#define RCLCPP_ERROR_STREAM_EXPRESSION(...)
1399
#define RCLCPP_ERROR_STREAM_FUNCTION(...)
1401
#define RCLCPP_ERROR_STREAM_SKIPFIRST(...)
1403
#define RCLCPP_ERROR_STREAM_THROTTLE(...)
1405
#define RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE(...)
1407
1408
#else
1409
// The RCLCPP_ERROR macro is surrounded by do { .. } while (0)
1410
// to implement the standard C macro idiom to make the macro safe in all
1411
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1419
#define RCLCPP_ERROR(logger, ...) \
1420
do { \
1421
static_assert( \
1422
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1423
typename ::rclcpp::Logger>::value, \
1424
"First argument to logging macros must be an rclcpp::Logger"); \
1425
\
1426
RCUTILS_LOG_ERROR_NAMED( \
1427
logger.get_name(), \
1428
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1429
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1430
} while (0)
1431
1432
// The RCLCPP_ERROR_ONCE macro is surrounded by do { .. } while (0)
1433
// to implement the standard C macro idiom to make the macro safe in all
1434
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1443
#define RCLCPP_ERROR_ONCE(logger, ...) \
1444
do { \
1445
static_assert( \
1446
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1447
typename ::rclcpp::Logger>::value, \
1448
"First argument to logging macros must be an rclcpp::Logger"); \
1449
\
1450
RCUTILS_LOG_ERROR_ONCE_NAMED( \
1451
logger.get_name(), \
1452
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1453
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1454
} while (0)
1455
1456
// The RCLCPP_ERROR_EXPRESSION macro is surrounded by do { .. } while (0)
1457
// to implement the standard C macro idiom to make the macro safe in all
1458
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1468
#define RCLCPP_ERROR_EXPRESSION(logger, expression, ...) \
1469
do { \
1470
static_assert( \
1471
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1472
typename ::rclcpp::Logger>::value, \
1473
"First argument to logging macros must be an rclcpp::Logger"); \
1474
\
1475
RCUTILS_LOG_ERROR_EXPRESSION_NAMED( \
1476
expression, \
1477
logger.get_name(), \
1478
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1479
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1480
} while (0)
1481
1482
// The RCLCPP_ERROR_FUNCTION macro is surrounded by do { .. } while (0)
1483
// to implement the standard C macro idiom to make the macro safe in all
1484
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1494
#define RCLCPP_ERROR_FUNCTION(logger, function, ...) \
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_FUNCTION_NAMED( \
1502
function, \
1503
logger.get_name(), \
1504
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1505
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1506
} while (0)
1507
1508
// The RCLCPP_ERROR_SKIPFIRST macro is surrounded by do { .. } while (0)
1509
// to implement the standard C macro idiom to make the macro safe in all
1510
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1519
#define RCLCPP_ERROR_SKIPFIRST(logger, ...) \
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
RCUTILS_LOG_ERROR_SKIPFIRST_NAMED( \
1527
logger.get_name(), \
1528
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1529
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1530
} while (0)
1531
1532
// The RCLCPP_ERROR_THROTTLE macro is surrounded by do { .. } while (0)
1533
// to implement the standard C macro idiom to make the macro safe in all
1534
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1545
#define RCLCPP_ERROR_THROTTLE(logger, clock, duration, ...) \
1546
do { \
1547
static_assert( \
1548
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1549
typename ::rclcpp::Logger>::value, \
1550
"First argument to logging macros must be an rclcpp::Logger"); \
1551
\
1552
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1553
try { \
1554
*time_point = c.now().nanoseconds(); \
1555
} catch (...) { \
1556
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1557
"[rclcpp|logging.hpp] RCLCPP_ERROR_THROTTLE could not get current time stamp\n"); \
1558
return RCUTILS_RET_ERROR; \
1559
} \
1560
return RCUTILS_RET_OK; \
1561
}; \
1562
\
1563
RCUTILS_LOG_ERROR_THROTTLE_NAMED( \
1564
get_time_point, \
1565
duration, \
1566
logger.get_name(), \
1567
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1568
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1569
} while (0)
1570
1571
// The RCLCPP_ERROR_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1572
// to implement the standard C macro idiom to make the macro safe in all
1573
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1585
#define RCLCPP_ERROR_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
1586
do { \
1587
static_assert( \
1588
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1589
typename ::rclcpp::Logger>::value, \
1590
"First argument to logging macros must be an rclcpp::Logger"); \
1591
\
1592
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1593
try { \
1594
*time_point = c.now().nanoseconds(); \
1595
} catch (...) { \
1596
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1597
"[rclcpp|logging.hpp] RCLCPP_ERROR_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1598
return RCUTILS_RET_ERROR; \
1599
} \
1600
return RCUTILS_RET_OK; \
1601
}; \
1602
\
1603
RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED( \
1604
get_time_point, \
1605
duration, \
1606
logger.get_name(), \
1607
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1608
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1609
} while (0)
1610
1611
// The RCLCPP_ERROR_STREAM macro is surrounded by do { .. } while (0)
1612
// to implement the standard C macro idiom to make the macro safe in all
1613
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1620
#define RCLCPP_ERROR_STREAM(logger, stream_arg) \
1621
do { \
1622
static_assert( \
1623
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1624
typename ::rclcpp::Logger>::value, \
1625
"First argument to logging macros must be an rclcpp::Logger"); \
1626
\
1627
std::stringstream ss; \
1628
ss << stream_arg; \
1629
RCUTILS_LOG_ERROR_NAMED( \
1630
logger.get_name(), \
1631
"%s", rclcpp::get_c_string(ss.str())); \
1632
} while (0)
1633
1634
// The RCLCPP_ERROR_STREAM_ONCE macro is surrounded by do { .. } while (0)
1635
// to implement the standard C macro idiom to make the macro safe in all
1636
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1644
#define RCLCPP_ERROR_STREAM_ONCE(logger, stream_arg) \
1645
do { \
1646
static_assert( \
1647
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1648
typename ::rclcpp::Logger>::value, \
1649
"First argument to logging macros must be an rclcpp::Logger"); \
1650
\
1651
std::stringstream ss; \
1652
ss << stream_arg; \
1653
RCUTILS_LOG_ERROR_ONCE_NAMED( \
1654
logger.get_name(), \
1655
"%s", rclcpp::get_c_string(ss.str())); \
1656
} while (0)
1657
1658
// The RCLCPP_ERROR_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
1659
// to implement the standard C macro idiom to make the macro safe in all
1660
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1669
#define RCLCPP_ERROR_STREAM_EXPRESSION(logger, expression, stream_arg) \
1670
do { \
1671
static_assert( \
1672
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1673
typename ::rclcpp::Logger>::value, \
1674
"First argument to logging macros must be an rclcpp::Logger"); \
1675
\
1676
std::stringstream ss; \
1677
ss << stream_arg; \
1678
RCUTILS_LOG_ERROR_EXPRESSION_NAMED( \
1679
expression, \
1680
logger.get_name(), \
1681
"%s", rclcpp::get_c_string(ss.str())); \
1682
} while (0)
1683
1684
// The RCLCPP_ERROR_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
1685
// to implement the standard C macro idiom to make the macro safe in all
1686
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1695
#define RCLCPP_ERROR_STREAM_FUNCTION(logger, function, stream_arg) \
1696
do { \
1697
static_assert( \
1698
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1699
typename ::rclcpp::Logger>::value, \
1700
"First argument to logging macros must be an rclcpp::Logger"); \
1701
\
1702
std::stringstream ss; \
1703
ss << stream_arg; \
1704
RCUTILS_LOG_ERROR_FUNCTION_NAMED( \
1705
function, \
1706
logger.get_name(), \
1707
"%s", rclcpp::get_c_string(ss.str())); \
1708
} while (0)
1709
1710
// The RCLCPP_ERROR_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
1711
// to implement the standard C macro idiom to make the macro safe in all
1712
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1720
#define RCLCPP_ERROR_STREAM_SKIPFIRST(logger, stream_arg) \
1721
do { \
1722
static_assert( \
1723
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1724
typename ::rclcpp::Logger>::value, \
1725
"First argument to logging macros must be an rclcpp::Logger"); \
1726
\
1727
std::stringstream ss; \
1728
ss << stream_arg; \
1729
RCUTILS_LOG_ERROR_SKIPFIRST_NAMED( \
1730
logger.get_name(), \
1731
"%s", rclcpp::get_c_string(ss.str())); \
1732
} while (0)
1733
1734
// The RCLCPP_ERROR_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
1735
// to implement the standard C macro idiom to make the macro safe in all
1736
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1746
#define RCLCPP_ERROR_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
1747
do { \
1748
static_assert( \
1749
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1750
typename ::rclcpp::Logger>::value, \
1751
"First argument to logging macros must be an rclcpp::Logger"); \
1752
\
1753
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1754
try { \
1755
*time_point = c.now().nanoseconds(); \
1756
} catch (...) { \
1757
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1758
"[rclcpp|logging.hpp] RCLCPP_ERROR_STREAM_THROTTLE could not get current time stamp\n"); \
1759
return RCUTILS_RET_ERROR; \
1760
} \
1761
return RCUTILS_RET_OK; \
1762
}; \
1763
\
1764
std::stringstream ss; \
1765
ss << stream_arg; \
1766
RCUTILS_LOG_ERROR_THROTTLE_NAMED( \
1767
get_time_point, \
1768
duration, \
1769
logger.get_name(), \
1770
"%s", rclcpp::get_c_string(ss.str())); \
1771
} while (0)
1772
1773
// The RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
1774
// to implement the standard C macro idiom to make the macro safe in all
1775
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1786
#define RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
1787
do { \
1788
static_assert( \
1789
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1790
typename ::rclcpp::Logger>::value, \
1791
"First argument to logging macros must be an rclcpp::Logger"); \
1792
\
1793
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1794
try { \
1795
*time_point = c.now().nanoseconds(); \
1796
} catch (...) { \
1797
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1798
"[rclcpp|logging.hpp] RCLCPP_ERROR_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
1799
return RCUTILS_RET_ERROR; \
1800
} \
1801
return RCUTILS_RET_OK; \
1802
}; \
1803
\
1804
std::stringstream ss; \
1805
ss << stream_arg; \
1806
RCUTILS_LOG_ERROR_SKIPFIRST_THROTTLE_NAMED( \
1807
get_time_point, \
1808
duration, \
1809
logger.get_name(), \
1810
"%s", rclcpp::get_c_string(ss.str())); \
1811
} while (0)
1812
1813
#endif
1814
1818
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_FATAL)
1820
// empty logging macros for severity FATAL when being disabled at compile time
1822
#define RCLCPP_FATAL(...)
1823
#define RCLCPP_FATAL_ONCE(...)
1825
#define RCLCPP_FATAL_EXPRESSION(...)
1827
#define RCLCPP_FATAL_FUNCTION(...)
1829
#define RCLCPP_FATAL_SKIPFIRST(...)
1831
#define RCLCPP_FATAL_THROTTLE(...)
1833
#define RCLCPP_FATAL_SKIPFIRST_THROTTLE(...)
1835
#define RCLCPP_FATAL_STREAM(...)
1837
#define RCLCPP_FATAL_STREAM_ONCE(...)
1839
#define RCLCPP_FATAL_STREAM_EXPRESSION(...)
1841
#define RCLCPP_FATAL_STREAM_FUNCTION(...)
1843
#define RCLCPP_FATAL_STREAM_SKIPFIRST(...)
1845
#define RCLCPP_FATAL_STREAM_THROTTLE(...)
1847
#define RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE(...)
1849
1850
#else
1851
// The RCLCPP_FATAL macro is surrounded by do { .. } while (0)
1852
// to implement the standard C macro idiom to make the macro safe in all
1853
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1861
#define RCLCPP_FATAL(logger, ...) \
1862
do { \
1863
static_assert( \
1864
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1865
typename ::rclcpp::Logger>::value, \
1866
"First argument to logging macros must be an rclcpp::Logger"); \
1867
\
1868
RCUTILS_LOG_FATAL_NAMED( \
1869
logger.get_name(), \
1870
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1871
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1872
} while (0)
1873
1874
// The RCLCPP_FATAL_ONCE macro is surrounded by do { .. } while (0)
1875
// to implement the standard C macro idiom to make the macro safe in all
1876
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1885
#define RCLCPP_FATAL_ONCE(logger, ...) \
1886
do { \
1887
static_assert( \
1888
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1889
typename ::rclcpp::Logger>::value, \
1890
"First argument to logging macros must be an rclcpp::Logger"); \
1891
\
1892
RCUTILS_LOG_FATAL_ONCE_NAMED( \
1893
logger.get_name(), \
1894
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1895
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1896
} while (0)
1897
1898
// The RCLCPP_FATAL_EXPRESSION macro is surrounded by do { .. } while (0)
1899
// to implement the standard C macro idiom to make the macro safe in all
1900
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1910
#define RCLCPP_FATAL_EXPRESSION(logger, expression, ...) \
1911
do { \
1912
static_assert( \
1913
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1914
typename ::rclcpp::Logger>::value, \
1915
"First argument to logging macros must be an rclcpp::Logger"); \
1916
\
1917
RCUTILS_LOG_FATAL_EXPRESSION_NAMED( \
1918
expression, \
1919
logger.get_name(), \
1920
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1921
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1922
} while (0)
1923
1924
// The RCLCPP_FATAL_FUNCTION macro is surrounded by do { .. } while (0)
1925
// to implement the standard C macro idiom to make the macro safe in all
1926
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1936
#define RCLCPP_FATAL_FUNCTION(logger, function, ...) \
1937
do { \
1938
static_assert( \
1939
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1940
typename ::rclcpp::Logger>::value, \
1941
"First argument to logging macros must be an rclcpp::Logger"); \
1942
\
1943
RCUTILS_LOG_FATAL_FUNCTION_NAMED( \
1944
function, \
1945
logger.get_name(), \
1946
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1947
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1948
} while (0)
1949
1950
// The RCLCPP_FATAL_SKIPFIRST macro is surrounded by do { .. } while (0)
1951
// to implement the standard C macro idiom to make the macro safe in all
1952
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1961
#define RCLCPP_FATAL_SKIPFIRST(logger, ...) \
1962
do { \
1963
static_assert( \
1964
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1965
typename ::rclcpp::Logger>::value, \
1966
"First argument to logging macros must be an rclcpp::Logger"); \
1967
\
1968
RCUTILS_LOG_FATAL_SKIPFIRST_NAMED( \
1969
logger.get_name(), \
1970
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
1971
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
1972
} while (0)
1973
1974
// The RCLCPP_FATAL_THROTTLE macro is surrounded by do { .. } while (0)
1975
// to implement the standard C macro idiom to make the macro safe in all
1976
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
1987
#define RCLCPP_FATAL_THROTTLE(logger, clock, duration, ...) \
1988
do { \
1989
static_assert( \
1990
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
1991
typename ::rclcpp::Logger>::value, \
1992
"First argument to logging macros must be an rclcpp::Logger"); \
1993
\
1994
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
1995
try { \
1996
*time_point = c.now().nanoseconds(); \
1997
} catch (...) { \
1998
RCUTILS_SAFE_FWRITE_TO_STDERR( \
1999
"[rclcpp|logging.hpp] RCLCPP_FATAL_THROTTLE could not get current time stamp\n"); \
2000
return RCUTILS_RET_ERROR; \
2001
} \
2002
return RCUTILS_RET_OK; \
2003
}; \
2004
\
2005
RCUTILS_LOG_FATAL_THROTTLE_NAMED( \
2006
get_time_point, \
2007
duration, \
2008
logger.get_name(), \
2009
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
2010
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
2011
} while (0)
2012
2013
// The RCLCPP_FATAL_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
2014
// to implement the standard C macro idiom to make the macro safe in all
2015
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2027
#define RCLCPP_FATAL_SKIPFIRST_THROTTLE(logger, clock, duration, ...) \
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
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
2035
try { \
2036
*time_point = c.now().nanoseconds(); \
2037
} catch (...) { \
2038
RCUTILS_SAFE_FWRITE_TO_STDERR( \
2039
"[rclcpp|logging.hpp] RCLCPP_FATAL_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
2040
return RCUTILS_RET_ERROR; \
2041
} \
2042
return RCUTILS_RET_OK; \
2043
}; \
2044
\
2045
RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED( \
2046
get_time_point, \
2047
duration, \
2048
logger.get_name(), \
2049
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
2050
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,"")); \
2051
} while (0)
2052
2053
// The RCLCPP_FATAL_STREAM macro is surrounded by do { .. } while (0)
2054
// to implement the standard C macro idiom to make the macro safe in all
2055
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2062
#define RCLCPP_FATAL_STREAM(logger, stream_arg) \
2063
do { \
2064
static_assert( \
2065
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2066
typename ::rclcpp::Logger>::value, \
2067
"First argument to logging macros must be an rclcpp::Logger"); \
2068
\
2069
std::stringstream ss; \
2070
ss << stream_arg; \
2071
RCUTILS_LOG_FATAL_NAMED( \
2072
logger.get_name(), \
2073
"%s", rclcpp::get_c_string(ss.str())); \
2074
} while (0)
2075
2076
// The RCLCPP_FATAL_STREAM_ONCE macro is surrounded by do { .. } while (0)
2077
// to implement the standard C macro idiom to make the macro safe in all
2078
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2086
#define RCLCPP_FATAL_STREAM_ONCE(logger, stream_arg) \
2087
do { \
2088
static_assert( \
2089
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2090
typename ::rclcpp::Logger>::value, \
2091
"First argument to logging macros must be an rclcpp::Logger"); \
2092
\
2093
std::stringstream ss; \
2094
ss << stream_arg; \
2095
RCUTILS_LOG_FATAL_ONCE_NAMED( \
2096
logger.get_name(), \
2097
"%s", rclcpp::get_c_string(ss.str())); \
2098
} while (0)
2099
2100
// The RCLCPP_FATAL_STREAM_EXPRESSION macro is surrounded by do { .. } while (0)
2101
// to implement the standard C macro idiom to make the macro safe in all
2102
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2111
#define RCLCPP_FATAL_STREAM_EXPRESSION(logger, expression, stream_arg) \
2112
do { \
2113
static_assert( \
2114
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2115
typename ::rclcpp::Logger>::value, \
2116
"First argument to logging macros must be an rclcpp::Logger"); \
2117
\
2118
std::stringstream ss; \
2119
ss << stream_arg; \
2120
RCUTILS_LOG_FATAL_EXPRESSION_NAMED( \
2121
expression, \
2122
logger.get_name(), \
2123
"%s", rclcpp::get_c_string(ss.str())); \
2124
} while (0)
2125
2126
// The RCLCPP_FATAL_STREAM_FUNCTION macro is surrounded by do { .. } while (0)
2127
// to implement the standard C macro idiom to make the macro safe in all
2128
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2137
#define RCLCPP_FATAL_STREAM_FUNCTION(logger, function, stream_arg) \
2138
do { \
2139
static_assert( \
2140
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2141
typename ::rclcpp::Logger>::value, \
2142
"First argument to logging macros must be an rclcpp::Logger"); \
2143
\
2144
std::stringstream ss; \
2145
ss << stream_arg; \
2146
RCUTILS_LOG_FATAL_FUNCTION_NAMED( \
2147
function, \
2148
logger.get_name(), \
2149
"%s", rclcpp::get_c_string(ss.str())); \
2150
} while (0)
2151
2152
// The RCLCPP_FATAL_STREAM_SKIPFIRST macro is surrounded by do { .. } while (0)
2153
// to implement the standard C macro idiom to make the macro safe in all
2154
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2162
#define RCLCPP_FATAL_STREAM_SKIPFIRST(logger, stream_arg) \
2163
do { \
2164
static_assert( \
2165
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2166
typename ::rclcpp::Logger>::value, \
2167
"First argument to logging macros must be an rclcpp::Logger"); \
2168
\
2169
std::stringstream ss; \
2170
ss << stream_arg; \
2171
RCUTILS_LOG_FATAL_SKIPFIRST_NAMED( \
2172
logger.get_name(), \
2173
"%s", rclcpp::get_c_string(ss.str())); \
2174
} while (0)
2175
2176
// The RCLCPP_FATAL_STREAM_THROTTLE macro is surrounded by do { .. } while (0)
2177
// to implement the standard C macro idiom to make the macro safe in all
2178
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2188
#define RCLCPP_FATAL_STREAM_THROTTLE(logger, clock, duration, stream_arg) \
2189
do { \
2190
static_assert( \
2191
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2192
typename ::rclcpp::Logger>::value, \
2193
"First argument to logging macros must be an rclcpp::Logger"); \
2194
\
2195
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
2196
try { \
2197
*time_point = c.now().nanoseconds(); \
2198
} catch (...) { \
2199
RCUTILS_SAFE_FWRITE_TO_STDERR( \
2200
"[rclcpp|logging.hpp] RCLCPP_FATAL_STREAM_THROTTLE could not get current time stamp\n"); \
2201
return RCUTILS_RET_ERROR; \
2202
} \
2203
return RCUTILS_RET_OK; \
2204
}; \
2205
\
2206
std::stringstream ss; \
2207
ss << stream_arg; \
2208
RCUTILS_LOG_FATAL_THROTTLE_NAMED( \
2209
get_time_point, \
2210
duration, \
2211
logger.get_name(), \
2212
"%s", rclcpp::get_c_string(ss.str())); \
2213
} while (0)
2214
2215
// The RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE macro is surrounded by do { .. } while (0)
2216
// to implement the standard C macro idiom to make the macro safe in all
2217
// contexts; see http://c-faq.com/cpp/multistmt.html for more information.
2228
#define RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE(logger, clock, duration, stream_arg) \
2229
do { \
2230
static_assert( \
2231
::std::is_same<typename std::remove_cv<typename std::remove_reference<decltype(logger)>::type>::type, \
2232
typename ::rclcpp::Logger>::value, \
2233
"First argument to logging macros must be an rclcpp::Logger"); \
2234
\
2235
auto get_time_point = [&c=clock](rcutils_time_point_value_t * time_point) -> rcutils_ret_t { \
2236
try { \
2237
*time_point = c.now().nanoseconds(); \
2238
} catch (...) { \
2239
RCUTILS_SAFE_FWRITE_TO_STDERR( \
2240
"[rclcpp|logging.hpp] RCLCPP_FATAL_STREAM_SKIPFIRST_THROTTLE could not get current time stamp\n"); \
2241
return RCUTILS_RET_ERROR; \
2242
} \
2243
return RCUTILS_RET_OK; \
2244
}; \
2245
\
2246
std::stringstream ss; \
2247
ss << stream_arg; \
2248
RCUTILS_LOG_FATAL_SKIPFIRST_THROTTLE_NAMED( \
2249
get_time_point, \
2250
duration, \
2251
logger.get_name(), \
2252
"%s", rclcpp::get_c_string(ss.str())); \
2253
} while (0)
2254
2255
#endif
2256
2258
2259
#endif // RCLCPP__LOGGING_HPP_
logging_macros.h
logger.hpp
utilities.hpp
Generated by
1.8.17