ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
Public Types | Public Member Functions | Friends | List of all members
rclcpp::Logger Class Reference

Public Types

enum class  Level {
  Unset = RCUTILS_LOG_SEVERITY_UNSET , Debug = RCUTILS_LOG_SEVERITY_DEBUG , Info = RCUTILS_LOG_SEVERITY_INFO , Warn = RCUTILS_LOG_SEVERITY_WARN ,
  Error = RCUTILS_LOG_SEVERITY_ERROR , Fatal = RCUTILS_LOG_SEVERITY_FATAL
}
 An enum for the type of logger level. More...
 

Public Member Functions

RCLCPP_PUBLIC const char * get_name () const
 Get the name of this logger. More...
 
RCLCPP_PUBLIC Logger get_child (const std::string &suffix)
 Return a logger that is a descendant of this logger. More...
 
RCLCPP_PUBLIC void set_level (Level level)
 Set level for current logger. More...
 
RCLCPP_PUBLIC Level get_effective_level () const
 Get effective level for current logger. More...
 

Friends

Logger rclcpp::get_logger (const std::string &name)
 

Detailed Description

Definition at line 121 of file logger.hpp.

Member Enumeration Documentation

◆ Level

enum rclcpp::Logger::Level
strong

An enum for the type of logger level.

Enumerator
Unset 

The unset log level.

Debug 

The debug log level.

Info 

The info log level.

Warn 

The warn log level.

Error 

The error log level.

Fatal 

The fatal log level.

Definition at line 125 of file logger.hpp.

Member Function Documentation

◆ get_child()

Logger rclcpp::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
[in]suffixthe child logger's suffix
Returns
a logger with the fully-qualified name including the suffix, or
a dummy logger if this logger is invalid (e.g. because logging is disabled).

Definition at line 101 of file logger.cpp.

References rcl_logging_rosout_add_sublogger(), rcl_logging_rosout_remove_sublogger(), RCL_RET_NOT_FOUND, and RCL_RET_OK.

Referenced by rclcpp::GenericService::GenericService(), rclcpp::PublisherBase::PublisherBase(), and rclcpp::SubscriptionBase::SubscriptionBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_effective_level()

Logger::Level rclcpp::Logger::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.

Exceptions
rclcpp::exceptions::RCLErrorif any error happens.
Returns
Level for the current logger.

Definition at line 159 of file logger.cpp.

References get_name(), and RCL_RET_ERROR.

Here is the call graph for this function:

◆ get_name()

RCLCPP_PUBLIC const char* rclcpp::Logger::get_name ( ) const
inline

Get the name of this logger.

Returns
the full name of the logger including any prefixes, or
nullptr if this logger is invalid (e.g. because logging is disabled).

Definition at line 166 of file logger.hpp.

Referenced by get_effective_level(), and set_level().

Here is the caller graph for this function:

◆ set_level()

void rclcpp::Logger::set_level ( Level  level)

Set level for current logger.

Parameters
[in]levelthe logger's level
Exceptions
rclcpp::exceptions::RCLInvalidArgumentif level is invalid.
rclcpp::exceptions::RCLErrorif other error happens.

Definition at line 141 of file logger.cpp.

References get_name(), RCL_RET_ERROR, and RCL_RET_INVALID_ARGUMENT.

Here is the call graph for this function:

The documentation for this class was generated from the following files: