rcutils  master
C API providing common utilities and data structures.
logging.h
Go to the documentation of this file.
1 // Copyright 2017 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCUTILS__LOGGING_H_
16 #define RCUTILS__LOGGING_H_
17 
18 #include <stdarg.h>
19 #include <stdbool.h>
20 #include <stdio.h>
21 
23 
24 #if __cplusplus
25 extern "C"
26 {
27 #endif
28 
31 extern bool g_rcl_logging_initialized;
32 
34 
47 
49 typedef struct rcl_log_location_t
50 {
52  const char * function_name;
54  const char * file_name;
56  size_t line_number;
58 
61 {
67 };
68 
70 
78  rcl_log_location_t *, // location
79  int, // severity
80  const char *, // name
81  const char *, // format
82  va_list * // args
83 );
84 
88 
90 
103 
105 
118 
120 
128 
130 
143 
145 
157 void rcl_logging_set_severity_threshold(int severity);
158 
160 
179 void rcl_log(
180  rcl_log_location_t * location,
181  int severity,
182  const char * name,
183  const char * format,
184  ...);
185 
187 
211  rcl_log_location_t * location,
212  int severity, const char * name, const char * format, va_list * args);
213 
214 #if __cplusplus
215 }
216 #endif
217 
218 #endif // RCUTILS__LOGGING_H_
const char * function_name
The name of the function containing the log call.
Definition: logging.h:52
The info log level.
Definition: logging.h:63
The warn log level.
Definition: logging.h:64
const char * file_name
The name of the source file containing the log call.
Definition: logging.h:54
void rcl_logging_set_output_handler(rcl_logging_output_handler_t function)
Set the current output handler.
void rcl_logging_console_output_handler(rcl_log_location_t *location, int severity, const char *name, const char *format, va_list *args)
The default output handler outputs log messages to the standard streams.
int g_rcl_logging_severity_threshold
The global severity threshold before calling the output handler.
void rcl_log(rcl_log_location_t *location, int severity, const char *name, const char *format,...)
Log a message.
struct rcl_log_location_t rcl_log_location_t
The structure identifying the caller location in the source code.
rcl_logging_output_handler_t g_rcl_logging_output_handler
The function pointer of the current output handler.
void rcl_logging_set_severity_threshold(int severity)
Set the global severity threshold.
void(* rcl_logging_output_handler_t)(rcl_log_location_t *, int, const char *, const char *, va_list *)
The function signature to log messages.
Definition: logging.h:77
size_t line_number
The line number containing the log call.
Definition: logging.h:56
RCUTILS_LOG_SEVERITY
The severity levels of log message.
Definition: logging.h:60
bool g_rcl_logging_initialized
The flag if the logging system has been initialized.
#define RCUTILS_PUBLIC
Definition: visibility_control.h:48
The fatal log level.
Definition: logging.h:66
rcl_logging_output_handler_t rcl_logging_get_output_handler()
Get the current output handler.
The structure identifying the caller location in the source code.
Definition: logging.h:49
The debug log level.
Definition: logging.h:62
int rcl_logging_get_severity_threshold()
Get the global severity threshold.
The error log level.
Definition: logging.h:65
void rcl_logging_initialize()
Initialize the logging system.