Classes | Namespaces | Typedefs | Functions
log_utils.h File Reference

ROS logging helpers. More...

#include <cstdarg>
#include <memory>
#include <string>
#include <ros/console.h>
#include <cras_cpp_common/string_utils.hpp>
#include <cras_cpp_common/log_utils/macros.h>
#include <cras_cpp_common/log_utils/deprecated/macros.h>
Include dependency graph for log_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cras::HasLogger
 Convenience base class for providing this->log and getCrasLogger(). Just add it as a base to your class and all CRAS_* logging macros should work with the logger from this class. More...
 
class  cras::LogHelper
 This class (reps. its descendants) provides unified access to ROS logging functions, be it ROS_* or NODELET_*. More...
 
class  cras::RosconsoleLogHelper
 Log helper relaying all of its work to the same mechanism used by ROS_* logging macros. More...
 
class  cras::WrapperLogHelper
 

Namespaces

 cras
 

Typedefs

typedef ::cras::LogHelper::ConstPtr cras::LogHelperConstPtr
 Const pointer to LogHelper. More...
 
typedef ::cras::LogHelper::Ptr cras::LogHelperPtr
 Pointer to LogHelper. More...
 

Functions

::cras::LogHelperConstPtr getCrasLogger ()
 Get the default logger used for CRAS_* logging macros. It will never be null. More...
 
int8_t cras::logLevelToRosgraphMsgLevel (::ros::console::Level rosLevel)
 Convert the given rosconsole logging level to rosgraph_msgs::Log level constant. More...
 
void restorePreviousCrasLogger ()
 
::ros::console::Level cras::rosgraphMsgLevelToLogLevel (uint8_t msgLevel)
 Convert the given rosgraph_msgs::Log level constant to rosconsole logging level. More...
 
::cras::LogHelperConstPtr setCrasLogger (const ::cras::LogHelperConstPtr &log)
 Set the default logger used by CRAS_* macros. More...
 

Detailed Description

ROS logging helpers.

Author
Martin Pecka

The idea of CRAS logging system is that your code should not care whether it is running in a node or a nodelet. So it provides unified CRAS_* logging macros similar to ROS_* macros, which automatically choose a suitable logger. This choice is performed by evaluating expression getCrasLogger() in the current context. By default, it picks up the getCrasLogger() global functions which returns a logger that mimicks the ROS_* macros. When writing code inside a nodelet, the base nodelet class provides an "override" of this method that returns a logger that mimicks NODELET_* macros. Filters also have their specialized default logger. And each of your classes can have, or you can even just define a local lambda called getCrasLogger that would return the logger to use. If you want to pass a logger explicitly, use the CRAS_LOG_* variants that take logger as the first argument. You can also write your own loggers that behave very differently.

Definition in file log_utils.h.

Function Documentation

◆ getCrasLogger()

::cras::LogHelperConstPtr getCrasLogger ( )

Get the default logger used for CRAS_* logging macros. It will never be null.

Returns
The logger.

◆ restorePreviousCrasLogger()

void restorePreviousCrasLogger ( )

◆ setCrasLogger()

::cras::LogHelperConstPtr setCrasLogger ( const ::cras::LogHelperConstPtr log)

Set the default logger used by CRAS_* macros.

Parameters
[in]logThe new logger.
Returns
The previous logger.


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 5 2024 03:50:30