Viam C++ SDK current
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
viam::sdk::LogManager Class Reference

Manages the logging infrastructure in the SDDK. More...

#include "log/logging.hpp"

Classes

struct  Filter
 

Public Member Functions

void set_global_resource_name (const std::string &name)
 Override the channel name of general log messages not originating from resources.
 
void set_global_log_level (log_level)
 Set the global logger severity.
 
void set_global_log_level (int argc, char **argv)
 Set the global logger severity from a command line argument vector.
 
void set_module_name (const std::string &name)
 Set the channel name of log messages to be associated with a C++ module.
 
void set_module_log_level (log_level)
 Set the module logger severity.
 
void set_resource_log_level (const std::string &resource, log_level)
 Set the logger severity for a resource.
 
LogSource & global_logger ()
 Return the SDK global log source.
 
LogSource & module_logger ()
 Return the SDK module log source.
 

Static Public Member Functions

static LogManager & get ()
 Returns the unique logger instance.
 

Friends

class RobotClient
 
class Instance
 

Detailed Description

Manages the logging infrastructure in the SDDK.

Handles initialization and bookkeeping for logging infrastructure in the C++ SDK. This includes console logging, if active, and both global and resource-level log filtering.

Member Function Documentation

◆ get()

static LogManager & viam::sdk::LogManager::get ( )
static

Returns the unique logger instance.

This is the only way to access the logger.

◆ global_logger()

LogSource & viam::sdk::LogManager::global_logger ( )

Return the SDK global log source.

Users should prefer to log messages using the logging macros below.

◆ module_logger()

LogSource & viam::sdk::LogManager::module_logger ( )

Return the SDK module log source.

Users should prefer to log messages using the logging macros below.

◆ set_global_log_level()

void viam::sdk::LogManager::set_global_log_level ( int argc,
char ** argv )

Set the global logger severity from a command line argument vector.

Sets severity to debug if "--log-level=debug" is the third argument. Sets severity to info otherwise. Useful for module implementations. See LogLevel documentation in the RDK for more information on how to start modules with a "log-level" commandline argument.

◆ set_module_name()

void viam::sdk::LogManager::set_module_name ( const std::string & name)

Set the channel name of log messages to be associated with a C++ module.

Remarks
The channel name will be set to the value of the environment variable VIAM_MODULE_NAME if set, otherwise it defaults to the value of default_module_name.

◆ set_resource_log_level()

void viam::sdk::LogManager::set_resource_log_level ( const std::string & resource,
log_level  )

Set the logger severity for a resource.

LogManager can maintain separate severity levels for individual resources. For example, you may want to only report "error" messages for global logs and logs for one component of a modular resource, but enable verbose logging for a new component that is still being debugged.

See also
Resource, which has a set_log_level method which automatically provides its own resource name.

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