configure-elpp-logger.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2022 Intel Corporation. All Rights Reserved.
3 
4 #ifdef BUILD_EASYLOGGINGPP
6 
7 namespace rsutils {
8 
9 
10 void configure_elpp_logger( bool enable_debug, std::string const & nested_indent, std::string const & logger_id )
11 {
12  el::Configurations defaultConf;
13 
14  el::Logger * logger = el::Loggers::getLogger( logger_id );
15  el::Configurations * configs;
16  if( logger )
17  {
18  configs = logger->configurations();
19  }
20  else
21  {
22  // First initialization
23  defaultConf.setToDefault();
26  configs = &defaultConf;
27  }
28 
29  std::string format = "-%levshort- %datetime{%H:%m:%s.%g} %msg (%fbase:%line [%thread])";
30  if( ! nested_indent.empty() )
31  format = '[' + nested_indent + "] " + format;
33 
34  auto enable_str = enable_debug ? "true" : "false";
38 
39  if( logger )
40  logger->reconfigure();
41  else
42  el::Loggers::reconfigureLogger( logger_id, defaultConf );
43 }
44 
45 
46 } // namespace rsutils
47 
48 #endif // BUILD_EASYLOGGINGPP
format
GLint GLint GLsizei GLint GLenum format
Definition: glad/glad/glad.h:1412
el::Logger
Represents a logger holding ID and configurations we need to write logs.
Definition: easylogging++.h:2217
easyloggingpp.h
el::ConfigurationType::Format
@ Format
Determines format of logging corresponding level and logger.
el::Configurations::setToDefault
void setToDefault(void)
Sets configurations to "factory based" configurations.
Definition: easylogging++.cc:364
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
el::Logger::configurations
Configurations * configurations(void)
Definition: easylogging++.h:2250
el::Level::Debug
@ Debug
Informational events most useful for developers to debug application.
test-control-reply.nested_indent
nested_indent
Definition: test-control-reply.py:14
el::Configurations::setGlobally
void setGlobally(ConfigurationType configurationType, const std::string &value)
Sets configuration for all levels.
Definition: easylogging++.h:1810
el::Level::Warning
@ Warning
Useful when application has potentially harmful situations.
el::Level::Info
@ Info
Mainly useful to represent current progress of application.
rsutils
Definition: dds-participant.h:30
el::Configurations
Thread-safe Configuration repository.
Definition: easylogging++.h:1733
el::Configurations::set
void set(Level level, ConfigurationType configurationType, const std::string &value)
Sets value of configuration for specified level.
Definition: easylogging++.cc:349
el::Loggers::getLogger
static Logger * getLogger(const std::string &identity, bool registerIfNotAvailable=true)
Gets existing or registers new logger.
Definition: easylogging++.cc:2953
el::Logger::reconfigure
void reconfigure(void)
Reconfigures logger using existing configurations.
Definition: easylogging++.cc:666
el::Loggers::reconfigureLogger
static Logger * reconfigureLogger(Logger *logger, const Configurations &configurations)
Reconfigures specified logger with new configurations.
Definition: easylogging++.cc:2969
el::ConfigurationType::ToStandardOutput
@ ToStandardOutput
Whether or not to write corresponding level and logger log to standard output. By standard output mea...
el::Level::Error
@ Error
Information representing errors in application but application will keep running.


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Fri Aug 2 2024 08:30:01