Class Logger

Class Documentation

class Logger

Public Types

enum class Level

An enum for the type of logger level.

Values:

enumerator Unset

The unset log level.

enumerator Debug

The debug log level.

enumerator Info

The info log level.

enumerator Warn

The warn log level.

enumerator Error

The error log level.

enumerator Fatal

The fatal log level.

Public Functions

Logger(const Logger&) = default
inline const char *get_name() const

Get the name of this logger.

Returns:

the full name of the logger including any prefixes, or

Returns:

nullptr if this logger is invalid (e.g. because logging is disabled).

Logger get_child(const std::string &suffix)

Return a logger that is a descendant of this logger.

The child logger’s full name will include any hierarchy conventions that indicate it is a descendant of this logger. For example, get_logger('abc').get_child('def') will return a logger with name abc.def.

Parameters:

suffix[in] the child logger’s suffix

Returns:

a logger with the fully-qualified name including the suffix, or

Returns:

a dummy logger if this logger is invalid (e.g. because logging is disabled).

void set_level(Level level)

Set level for current logger.

Parameters:

level[in] the logger’s level

Throws:
Level get_effective_level() const

Get effective level for current logger.

The effective level is determined as the severity level of the logger if it is set, otherwise it is the first specified severity level of the logger’s ancestors, starting with its closest ancestor. The ancestor hierarchy is signified by logger names being separated by dots: a logger named x is an ancestor of x.y, and both x and x.y are ancestors of x.y.z, etc. If the level has not been set for the logger nor any of its ancestors, the default level is used.

Throws:

rclcpp::exceptions::RCLError – if any error happens.

Returns:

Level for the current logger.