LoggerBase Class
Base class to allow Behaviors to report messages with detailed explanations to MoveIt Studio UI. More...
Declaration
Included Headers
Derived Classes
| class | LoggerROS |
|
A ROS-specialized implementation of LoggerBase that publishes the error message on a topic and logs it through an rclcpp Logger. More... | |
Public Member Typedefs Index
| using | LogFilter = std::function< LogFilterAction(int32_t, const std::string &)> |
|
A filter invoked for every message published through this logger. More... | |
Enumerations Index
| enum class | LogFilterAction { ... } |
|
Action a LogFilter returns to tell the logger how to handle a message. More... | |
Public Destructor Index
| ~LoggerBase ()=default | |
Public Member Functions Index
| void | publishFailureMessage (const std::string &error_source_name, const std::string &details="") |
|
Helper function that wraps publishMessage with a preset ERROR log level. More... | |
| void | publishWarnMessage (const std::string &source_name, const std::string &details="") |
|
Helper function that wraps publishMessage with a preset WARN log level. More... | |
| void | publishInfoMessage (const std::string &source_name, const std::string &details="") |
|
Helper function that wraps publishMessage with a preset INFO log level. More... | |
| void | publishDebugMessage (const std::string &source_name, const std::string &details="") |
|
Helper function that wraps publishMessage with a preset DEBUG log level. More... | |
| void | publishMessage (const int32_t log_level, const std::string &source_name, const std::string &details) |
|
Function to publish a message. More... | |
| std::string | consumeErrorLogBuffer () |
|
Helper function to get the error log buffer. More... | |
| std::shared_ptr< void > | pushFilter (LogFilter filter) |
|
Push a filter onto the active filter stack. More... | |
| void | publishMessage (const int32_t log_level, const std::string &details) |
|
Function to publish a message. The default implementation logs to spdlog. LoggerROS is a good example of a subclass that overrides this, in which it publishes the message to a ROS topic and also calls this superclass function to also log to console. More... | |
Private Member Functions Index
| LogFilterAction | applyFilters (const int32_t log_level, const std::string &details) const |
|
Apply the top-of-stack filter (if any) to a message. More... | |
Private Member Attributes Index
| std::vector< std::string > | error_log_buffer_ |
|
Buffer for collecting logs. Guarded by error_log_buffer_mutex_ because messages may be appended from Behavior background threads (e.g. AsyncBehaviorBase) while the Objective end-handler drains it. More... | |
| std::mutex | error_log_buffer_mutex_ |
|
Mutex guarding error_log_buffer_. More... | |
| std::shared_ptr< FilterStack > | filter_stack_ = std::make_shared<FilterStack>() |
|
Shared filter-stack state; see FilterStack. Never null — created once and outlives any token only through that token's weak_ptr. More... | |
Description
Base class to allow Behaviors to report messages with detailed explanations to MoveIt Studio UI.
Definition at line 27 of file logger.hpp.
Public Member Typedefs
LogFilter
|
A filter invoked for every message published through this logger.
- Parameters
-
log_level The severity of the message (moveit_studio_agent_msgs::msg::Log::ERROR/WARN/INFO/DEBUG).
details The fully-formatted message text (including the source name and level string).
- Returns
Forward to publish the message normally, or Drop to suppress it entirely.
Definition at line 94 of file logger.hpp.
Enumerations
LogFilterAction
| strong |
Action a LogFilter returns to tell the logger how to handle a message.
The filter is consulted on the public publishMessage funnel, before the message is dispatched to the virtual publish path. Drop suppresses the message entirely (no console, no error buffer, no ROS topic, and so no UI toast); Forward leaves the message untouched and publishes it as if no filter were installed.
Definition at line 82 of file logger.hpp.
Public Destructor
~LoggerBase()
| virtual default |
Definition at line 30 of file logger.hpp.
Public Member Functions
consumeErrorLogBuffer()
| virtual |
Helper function to get the error log buffer.
- Returns
A string containing all the error logs in the buffer, separated by new lines
This function clears out the logs once retrieved
Declaration at line 74 of file logger.hpp, definition at line 172 of file logger.cpp.
publishDebugMessage()
|
Helper function that wraps publishMessage with a preset DEBUG log level.
- Parameters
-
source_name Name used to identify the source of the debug message.
details A detailed debug message.
Declaration at line 59 of file logger.hpp, definition at line 67 of file logger.cpp.
publishFailureMessage()
|
Helper function that wraps publishMessage with a preset ERROR log level.
- Parameters
-
error_source_name Name used to identify the source of the failure.
details A detailed message describing the failure. For example, the contents of an exception's message.
Declaration at line 38 of file logger.hpp, definition at line 52 of file logger.cpp.
publishInfoMessage()
|
Helper function that wraps publishMessage with a preset INFO log level.
- Parameters
-
source_name Name used to identify the source of the info.
details A detailed message describing the information.
Declaration at line 52 of file logger.hpp, definition at line 62 of file logger.cpp.
publishMessage()
|
Function to publish a message.
- Parameters
-
log_level moveit_studio_agent_msgs::msg::Log::ERROR/WARN/INFO/DEBUG
source_name Name used to identify the source of the log.
details Contains the information message
Declaration at line 67 of file logger.hpp, definition at line 72 of file logger.cpp.
publishMessage()
| virtual |
Function to publish a message. The default implementation logs to spdlog. LoggerROS is a good example of a subclass that overrides this, in which it publishes the message to a ROS topic and also calls this superclass function to also log to console.
- Parameters
-
log_level moveit_studio_agent_msgs::msg::Log::ERROR/WARN/INFO/DEBUG
details Contains the information message
Declaration at line 115 of file logger.hpp, definition at line 136 of file logger.cpp.
publishWarnMessage()
|
Helper function that wraps publishMessage with a preset WARN log level.
- Parameters
-
source_name Name used to identify the source of the warning.
details A detailed message describing the warning.
Declaration at line 45 of file logger.hpp, definition at line 57 of file logger.cpp.
pushFilter()
|
Push a filter onto the active filter stack.
The returned RAII token pops this filter (under the filter mutex) when it is destroyed. Only the top (most recently pushed) filter is consulted per message — there is no fallthrough from a Forward to the filters beneath it; while an inner filter is installed, the outer ones are dormant. In the normal single-filter case this is moot. If filters are nested (e.g. nested SuppressChildErrors decorators), only the innermost filter's decision applies to messages logged while it is on top. Thread-safe.
- Parameters
-
filter The filter to install. Must not be empty.
- Returns
An opaque ownership token. Reset or destroy it to remove the filter.
Declaration at line 106 of file logger.hpp, definition at line 105 of file logger.cpp.
Private Member Functions
applyFilters()
|
Apply the top-of-stack filter (if any) to a message.
Copies the top filter out from under the filter-stack mutex and invokes it with the lock released, so a callback that itself logs cannot self-deadlock and there is no lock-order inversion with any mutex the callback takes.
- Returns
The filter's action, or Forward when the stack is empty.
Declaration at line 125 of file logger.hpp, definition at line 89 of file logger.cpp.
Private Member Attributes
error_log_buffer_
|
Buffer for collecting logs. Guarded by error_log_buffer_mutex_ because messages may be appended from Behavior background threads (e.g. AsyncBehaviorBase) while the Objective end-handler drains it.
Definition at line 189 of file logger.hpp.
error_log_buffer_mutex_
|
Mutex guarding error_log_buffer_.
Definition at line 194 of file logger.hpp.
filter_stack_
|
Shared filter-stack state; see FilterStack. Never null — created once and outlives any token only through that token's weak_ptr.
Definition at line 200 of file logger.hpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.