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 <type_traits>
21
22
#include "
rclcpp/logger.hpp
"
23
#include "
rcutils/logging_macros.h
"
24
#include "
rclcpp/utilities.hpp
"
25
26
// These are used for compiling out logging macros lower than a minimum severity.
27
#define RCLCPP_LOG_MIN_SEVERITY_DEBUG 0
28
#define RCLCPP_LOG_MIN_SEVERITY_INFO 1
29
#define RCLCPP_LOG_MIN_SEVERITY_WARN 2
30
#define RCLCPP_LOG_MIN_SEVERITY_ERROR 3
31
#define RCLCPP_LOG_MIN_SEVERITY_FATAL 4
32
#define RCLCPP_LOG_MIN_SEVERITY_NONE 5
33
34
#define RCLCPP_FIRST_ARG(N, ...) N
35
#define RCLCPP_ALL_BUT_FIRST_ARGS(N, ...) __VA_ARGS__
36
43
#ifndef RCLCPP_LOG_MIN_SEVERITY
44
#define RCLCPP_LOG_MIN_SEVERITY RCLCPP_LOG_MIN_SEVERITY_DEBUG
45
#endif
46
49
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_DEBUG)
51
// empty logging macros for severity DEBUG when being disabled at compile time
53
#define RCLCPP_DEBUG(...)
54
#define RCLCPP_DEBUG_ONCE(...)
56
#define RCLCPP_DEBUG_EXPRESSION(...)
58
#define RCLCPP_DEBUG_FUNCTION(...)
60
#define RCLCPP_DEBUG_SKIPFIRST(...)
62
63
#else
64
71
#define RCLCPP_DEBUG(logger, ...) \
72
static_assert( \
73
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
74
typename ::rclcpp::Logger>::value, \
75
"First argument to logging macros must be an rclcpp::Logger"); \
76
RCUTILS_LOG_DEBUG_NAMED( \
77
logger.get_name(), \
78
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
79
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
80
89
#define RCLCPP_DEBUG_ONCE(logger, ...) \
90
static_assert( \
91
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
92
typename ::rclcpp::Logger>::value, \
93
"First argument to logging macros must be an rclcpp::Logger"); \
94
RCUTILS_LOG_DEBUG_ONCE_NAMED( \
95
logger.get_name(), \
96
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
97
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
98
108
#define RCLCPP_DEBUG_EXPRESSION(logger, expression, ...) \
109
static_assert( \
110
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
111
typename ::rclcpp::Logger>::value, \
112
"First argument to logging macros must be an rclcpp::Logger"); \
113
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED( \
114
expression, \
115
logger.get_name(), \
116
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
117
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
118
128
#define RCLCPP_DEBUG_FUNCTION(logger, function, ...) \
129
static_assert( \
130
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
131
typename ::rclcpp::Logger>::value, \
132
"First argument to logging macros must be an rclcpp::Logger"); \
133
RCUTILS_LOG_DEBUG_FUNCTION_NAMED( \
134
function, \
135
logger.get_name(), \
136
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
137
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
138
147
#define RCLCPP_DEBUG_SKIPFIRST(logger, ...) \
148
static_assert( \
149
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
150
typename ::rclcpp::Logger>::value, \
151
"First argument to logging macros must be an rclcpp::Logger"); \
152
RCUTILS_LOG_DEBUG_SKIPFIRST_NAMED( \
153
logger.get_name(), \
154
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
155
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
156
157
#endif
158
162
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_INFO)
164
// empty logging macros for severity INFO when being disabled at compile time
166
#define RCLCPP_INFO(...)
167
#define RCLCPP_INFO_ONCE(...)
169
#define RCLCPP_INFO_EXPRESSION(...)
171
#define RCLCPP_INFO_FUNCTION(...)
173
#define RCLCPP_INFO_SKIPFIRST(...)
175
176
#else
177
184
#define RCLCPP_INFO(logger, ...) \
185
static_assert( \
186
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
187
typename ::rclcpp::Logger>::value, \
188
"First argument to logging macros must be an rclcpp::Logger"); \
189
RCUTILS_LOG_INFO_NAMED( \
190
logger.get_name(), \
191
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
192
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
193
202
#define RCLCPP_INFO_ONCE(logger, ...) \
203
static_assert( \
204
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
205
typename ::rclcpp::Logger>::value, \
206
"First argument to logging macros must be an rclcpp::Logger"); \
207
RCUTILS_LOG_INFO_ONCE_NAMED( \
208
logger.get_name(), \
209
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
210
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
211
221
#define RCLCPP_INFO_EXPRESSION(logger, expression, ...) \
222
static_assert( \
223
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
224
typename ::rclcpp::Logger>::value, \
225
"First argument to logging macros must be an rclcpp::Logger"); \
226
RCUTILS_LOG_INFO_EXPRESSION_NAMED( \
227
expression, \
228
logger.get_name(), \
229
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
230
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
231
241
#define RCLCPP_INFO_FUNCTION(logger, function, ...) \
242
static_assert( \
243
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
244
typename ::rclcpp::Logger>::value, \
245
"First argument to logging macros must be an rclcpp::Logger"); \
246
RCUTILS_LOG_INFO_FUNCTION_NAMED( \
247
function, \
248
logger.get_name(), \
249
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
250
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
251
260
#define RCLCPP_INFO_SKIPFIRST(logger, ...) \
261
static_assert( \
262
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
263
typename ::rclcpp::Logger>::value, \
264
"First argument to logging macros must be an rclcpp::Logger"); \
265
RCUTILS_LOG_INFO_SKIPFIRST_NAMED( \
266
logger.get_name(), \
267
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
268
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
269
270
#endif
271
275
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_WARN)
277
// empty logging macros for severity WARN when being disabled at compile time
279
#define RCLCPP_WARN(...)
280
#define RCLCPP_WARN_ONCE(...)
282
#define RCLCPP_WARN_EXPRESSION(...)
284
#define RCLCPP_WARN_FUNCTION(...)
286
#define RCLCPP_WARN_SKIPFIRST(...)
288
289
#else
290
297
#define RCLCPP_WARN(logger, ...) \
298
static_assert( \
299
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
300
typename ::rclcpp::Logger>::value, \
301
"First argument to logging macros must be an rclcpp::Logger"); \
302
RCUTILS_LOG_WARN_NAMED( \
303
logger.get_name(), \
304
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
305
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
306
315
#define RCLCPP_WARN_ONCE(logger, ...) \
316
static_assert( \
317
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
318
typename ::rclcpp::Logger>::value, \
319
"First argument to logging macros must be an rclcpp::Logger"); \
320
RCUTILS_LOG_WARN_ONCE_NAMED( \
321
logger.get_name(), \
322
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
323
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
324
334
#define RCLCPP_WARN_EXPRESSION(logger, expression, ...) \
335
static_assert( \
336
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
337
typename ::rclcpp::Logger>::value, \
338
"First argument to logging macros must be an rclcpp::Logger"); \
339
RCUTILS_LOG_WARN_EXPRESSION_NAMED( \
340
expression, \
341
logger.get_name(), \
342
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
343
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
344
354
#define RCLCPP_WARN_FUNCTION(logger, function, ...) \
355
static_assert( \
356
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
357
typename ::rclcpp::Logger>::value, \
358
"First argument to logging macros must be an rclcpp::Logger"); \
359
RCUTILS_LOG_WARN_FUNCTION_NAMED( \
360
function, \
361
logger.get_name(), \
362
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
363
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
364
373
#define RCLCPP_WARN_SKIPFIRST(logger, ...) \
374
static_assert( \
375
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
376
typename ::rclcpp::Logger>::value, \
377
"First argument to logging macros must be an rclcpp::Logger"); \
378
RCUTILS_LOG_WARN_SKIPFIRST_NAMED( \
379
logger.get_name(), \
380
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
381
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
382
383
#endif
384
388
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_ERROR)
390
// empty logging macros for severity ERROR when being disabled at compile time
392
#define RCLCPP_ERROR(...)
393
#define RCLCPP_ERROR_ONCE(...)
395
#define RCLCPP_ERROR_EXPRESSION(...)
397
#define RCLCPP_ERROR_FUNCTION(...)
399
#define RCLCPP_ERROR_SKIPFIRST(...)
401
402
#else
403
410
#define RCLCPP_ERROR(logger, ...) \
411
static_assert( \
412
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
413
typename ::rclcpp::Logger>::value, \
414
"First argument to logging macros must be an rclcpp::Logger"); \
415
RCUTILS_LOG_ERROR_NAMED( \
416
logger.get_name(), \
417
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
418
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
419
428
#define RCLCPP_ERROR_ONCE(logger, ...) \
429
static_assert( \
430
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
431
typename ::rclcpp::Logger>::value, \
432
"First argument to logging macros must be an rclcpp::Logger"); \
433
RCUTILS_LOG_ERROR_ONCE_NAMED( \
434
logger.get_name(), \
435
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
436
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
437
447
#define RCLCPP_ERROR_EXPRESSION(logger, expression, ...) \
448
static_assert( \
449
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
450
typename ::rclcpp::Logger>::value, \
451
"First argument to logging macros must be an rclcpp::Logger"); \
452
RCUTILS_LOG_ERROR_EXPRESSION_NAMED( \
453
expression, \
454
logger.get_name(), \
455
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
456
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
457
467
#define RCLCPP_ERROR_FUNCTION(logger, function, ...) \
468
static_assert( \
469
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
470
typename ::rclcpp::Logger>::value, \
471
"First argument to logging macros must be an rclcpp::Logger"); \
472
RCUTILS_LOG_ERROR_FUNCTION_NAMED( \
473
function, \
474
logger.get_name(), \
475
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
476
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
477
486
#define RCLCPP_ERROR_SKIPFIRST(logger, ...) \
487
static_assert( \
488
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
489
typename ::rclcpp::Logger>::value, \
490
"First argument to logging macros must be an rclcpp::Logger"); \
491
RCUTILS_LOG_ERROR_SKIPFIRST_NAMED( \
492
logger.get_name(), \
493
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
494
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
495
496
#endif
497
501
#if (RCLCPP_LOG_MIN_SEVERITY > RCLCPP_LOG_MIN_SEVERITY_FATAL)
503
// empty logging macros for severity FATAL when being disabled at compile time
505
#define RCLCPP_FATAL(...)
506
#define RCLCPP_FATAL_ONCE(...)
508
#define RCLCPP_FATAL_EXPRESSION(...)
510
#define RCLCPP_FATAL_FUNCTION(...)
512
#define RCLCPP_FATAL_SKIPFIRST(...)
514
515
#else
516
523
#define RCLCPP_FATAL(logger, ...) \
524
static_assert( \
525
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
526
typename ::rclcpp::Logger>::value, \
527
"First argument to logging macros must be an rclcpp::Logger"); \
528
RCUTILS_LOG_FATAL_NAMED( \
529
logger.get_name(), \
530
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
531
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
532
541
#define RCLCPP_FATAL_ONCE(logger, ...) \
542
static_assert( \
543
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
544
typename ::rclcpp::Logger>::value, \
545
"First argument to logging macros must be an rclcpp::Logger"); \
546
RCUTILS_LOG_FATAL_ONCE_NAMED( \
547
logger.get_name(), \
548
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
549
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
550
560
#define RCLCPP_FATAL_EXPRESSION(logger, expression, ...) \
561
static_assert( \
562
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
563
typename ::rclcpp::Logger>::value, \
564
"First argument to logging macros must be an rclcpp::Logger"); \
565
RCUTILS_LOG_FATAL_EXPRESSION_NAMED( \
566
expression, \
567
logger.get_name(), \
568
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
569
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
570
580
#define RCLCPP_FATAL_FUNCTION(logger, function, ...) \
581
static_assert( \
582
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
583
typename ::rclcpp::Logger>::value, \
584
"First argument to logging macros must be an rclcpp::Logger"); \
585
RCUTILS_LOG_FATAL_FUNCTION_NAMED( \
586
function, \
587
logger.get_name(), \
588
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
589
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
590
599
#define RCLCPP_FATAL_SKIPFIRST(logger, ...) \
600
static_assert( \
601
::std::is_same<typename std::remove_reference<decltype(logger)>::type, \
602
typename ::rclcpp::Logger>::value, \
603
"First argument to logging macros must be an rclcpp::Logger"); \
604
RCUTILS_LOG_FATAL_SKIPFIRST_NAMED( \
605
logger.get_name(), \
606
rclcpp::get_c_string(RCLCPP_FIRST_ARG(__VA_ARGS__, "")), \
607
RCLCPP_ALL_BUT_FIRST_ARGS(__VA_ARGS__,""))
608
609
#endif
610
612
613
#endif // RCLCPP__LOGGING_HPP_
logger.hpp
logging_macros.h
utilities.hpp
Generated by
1.8.13