rcl_logging_spdlog  master
Implementation of rcl_logging API for an spdlog backend.
All Files Functions Enumerations Enumerator Macros Pages
Enumerations | Functions
rcl_logging_interface.h File Reference
#include "rcl_logging_interface/visibility_control.h"
#include "rcutils/allocator.h"
Include dependency graph for rcl_logging_interface.h:

Go to the source code of this file.

Enumerations

enum  rcl_logging_ret_t {
  RCL_LOGGING_RET_OK = 0, RCL_LOGGING_RET_ERROR = 2, RCL_LOGGING_RET_INVALID_ARGUMENT = 11, RCL_LOGGING_RET_CONFIG_FILE_DOESNT_EXIST = 21,
  RCL_LOGGING_RET_CONFIG_FILE_INVALID = 22
}
 

Functions

RCL_LOGGING_INTERFACE_PUBLIC RCUTILS_WARN_UNUSED rcl_logging_ret_t rcl_logging_external_initialize (const char *config_file, rcutils_allocator_t allocator)
 Initialize the external logging library. More...
 
RCL_LOGGING_INTERFACE_PUBLIC RCUTILS_WARN_UNUSED rcl_logging_ret_t rcl_logging_external_shutdown ()
 Free the resources allocated for the external logging system. More...
 
RCL_LOGGING_INTERFACE_PUBLIC void rcl_logging_external_log (int severity, const char *name, const char *msg)
 Log a message. More...
 
RCL_LOGGING_INTERFACE_PUBLIC RCUTILS_WARN_UNUSED rcl_logging_ret_t rcl_logging_external_set_logger_level (const char *name, int level)
 Set the severity level for a logger. More...
 
RCL_LOGGING_INTERFACE_PUBLIC rcl_logging_ret_t rcl_logging_get_logging_directory (rcutils_allocator_t allocator, char **directory)
 Get the logging directory. More...
 

Enumeration Type Documentation

◆ rcl_logging_ret_t

Enumerator
RCL_LOGGING_RET_OK 
RCL_LOGGING_RET_ERROR 
RCL_LOGGING_RET_INVALID_ARGUMENT 
RCL_LOGGING_RET_CONFIG_FILE_DOESNT_EXIST 
RCL_LOGGING_RET_CONFIG_FILE_INVALID 

Function Documentation

◆ rcl_logging_external_initialize()

RCL_LOGGING_INTERFACE_PUBLIC RCUTILS_WARN_UNUSED rcl_logging_ret_t rcl_logging_external_initialize ( const char *  config_file,
rcutils_allocator_t  allocator 
)

Initialize the external logging library.

Parameters
[in]config_fileThe location of a config file that the external logging library should use to configure itself. If provided, it must be a null terminated C string. If set to NULL or the empty string, the logging library will use defaults.
[in]allocatorThe allocator to use for memory allocation. This is an rcutils_allocator_t rather than an rcl_allocator_t to ensure that the rcl_logging_* packages don't have a circular dependency back to rcl.
Returns
RCL_LOGGING_RET_OK if initialized successfully.
RCL_LOGGING_RET_ERROR if an unspecified error occurs.
RCL_LOGGING_RET_CONFIG_FILE_DOESNT_EXIST if a config_file is provided but the file doesn't exist.
RCL_LOGGING_RET_CONFIG_FILE_INVALID if a config_file is provided but the logging backend doesn't understand it.

◆ rcl_logging_external_shutdown()

RCL_LOGGING_INTERFACE_PUBLIC RCUTILS_WARN_UNUSED rcl_logging_ret_t rcl_logging_external_shutdown ( )

Free the resources allocated for the external logging system.

This puts the system into a state equivalent to being uninitialized.

Returns
RCL_LOGGING_RET_OK if successfully shutdown, or
RCL_LOGGING_RET_ERROR if an unspecified error occurs.

◆ rcl_logging_external_log()

RCL_LOGGING_INTERFACE_PUBLIC void rcl_logging_external_log ( int  severity,
const char *  name,
const char *  msg 
)

Log a message.

Parameters
[in]severityThe severity level of the message being logged.
[in]nameThe name of the logger, must either be a null terminated C string or NULL. If NULL or empty the root logger will be used.
[in]msgThe message to be logged. Must be a null terminated C string.

◆ rcl_logging_external_set_logger_level()

RCL_LOGGING_INTERFACE_PUBLIC RCUTILS_WARN_UNUSED rcl_logging_ret_t rcl_logging_external_set_logger_level ( const char *  name,
int  level 
)

Set the severity level for a logger.

This function sets the severity level for the specified logger. If the name provided is an empty string or NULL it will change the level of the root logger.

Parameters
[in]nameThe name of the logger. Must be a null terminated C string or NULL.
[in]levelThe severity level to be used for the specified logger.
Returns
RCL_LOGGING_RET_OK if set successfully, or
RCL_LOGGING_RET_ERROR if an unspecified error occurs.

◆ rcl_logging_get_logging_directory()

RCL_LOGGING_INTERFACE_PUBLIC rcl_logging_ret_t rcl_logging_get_logging_directory ( rcutils_allocator_t  allocator,
char **  directory 
)

Get the logging directory.

Uses various environment variables to construct a logging directory path.

Use $ROS_LOG_DIR if ROS_LOG_DIR is set and not empty. Otherwise, use $ROS_HOME/log, using ~/.ros for ROS_HOME if not set or if empty.

It also expands an initial '~' to the current user's home directory, and converts the path separator if necessary.

If successful, the directory C string should be deallocated using the given allocator when it is no longer needed.

Parameters
[in]allocatorThe allocator to use for memory allocation.
[out]directoryThe C string pointer at which to write the directory path. Only meaningful if the call is successful. Must not be nullptr and must point to nullptr.
Returns
RCL_LOGGING_RET_OK if successful, or
RCL_LOGGING_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_LOGGING_RET_ERROR if an unspecified error occurs.