OpenRTM-aist 2.1.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
RTC::Logger Class Reference

Logger class. More...

#include <SystemLogger.h>

Inheritance diagram for RTC::Logger:
Inheritance graph
[legend]
Collaboration diagram for RTC::Logger:
Collaboration graph
[legend]

Public Types

enum  {
  RTL_SILENT , RTL_FATAL , RTL_ERROR , RTL_WARN ,
  RTL_INFO , RTL_DEBUG , RTL_TRACE , RTL_VERBOSE ,
  RTL_PARANOID
}
 

Public Member Functions

 Logger (const char *name="")
 Constructor.
 
 Logger (LogStreamBuf *streambuf)
 Constructor.
 
 ~Logger () override
 Virtual destructor.
 
bool setLevel (const char *level)
 Set log level by string.
 
void setDateFormat (const char *format)
 Set date/time format for adding the header.
 
void setClockType (const std::string &clocktype)
 Specifying clock type to be used for logging.
 
void setName (const char *name)
 Set suffix of date/time string of header.
 
void write (int level, const std::string &mes) override
 log output
 
void write (int level, const coil::Properties &prop)
 log output
 

Static Public Member Functions

static std::string getLevelString (int level)
 
static std::string getLevelOutputString (int level)
 
static std::string getLevelColor (int level)
 

Protected Member Functions

std::string getDate ()
 Get the current formatted date/time string Get the current datetime described by specified format.
 

Static Protected Member Functions

static int strToLevel (const char *level)
 Set the log level Set the log level corresponding to the given string.
 

Detailed Description

Logger class.

This class is composed of the buffer class and the format class.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
RTL_SILENT 
RTL_FATAL 
RTL_ERROR 
RTL_WARN 
RTL_INFO 
RTL_DEBUG 
RTL_TRACE 
RTL_VERBOSE 
RTL_PARANOID 

Constructor & Destructor Documentation

◆ Logger() [1/2]

RTC::Logger::Logger ( const char *  name = "")
explicit

Constructor.

Constructor

Parameters
namesuffix of date/time string of header.

◆ Logger() [2/2]

RTC::Logger::Logger ( LogStreamBuf streambuf)
explicit

Constructor.

Constructor

Parameters
streambufLogStream object

◆ ~Logger()

RTC::Logger::~Logger ( )
override

Virtual destructor.

Member Function Documentation

◆ getDate()

std::string RTC::Logger::getDate ( )
protected

Get the current formatted date/time string Get the current datetime described by specified format.

◆ getLevelColor()

static std::string RTC::Logger::getLevelColor ( int  level)
inlinestatic
Parameters
levellog level
Returns
string

◆ getLevelOutputString()

static std::string RTC::Logger::getLevelOutputString ( int  level)
inlinestatic
Parameters
levellog level
Returns
string

◆ getLevelString()

static std::string RTC::Logger::getLevelString ( int  level)
inlinestatic
Parameters
levellog level
Returns
string

◆ setClockType()

void RTC::Logger::setClockType ( const std::string &  clocktype)

Specifying clock type to be used for logging.

This function sets a clock type getting time when it is used for logging. Available clock types are,

  • system: System clock. Default option.
  • logical: Logical time clock.
  • adjusted: Adjusted clock.

To use logical time clock, call and set time by the following function in somewhere.

coil::ClockManager::instance().getClock("logical").settime()
Parameters
clocktypeA clock type above mentioned

◆ setDateFormat()

void RTC::Logger::setDateFormat ( const char *  format)

Set date/time format for adding the header.

The format specification string is as follows:

%a abbreviated weekday name
%A full weekday name
%b abbreviated month name
%B full month name
%c the standard date and time string
%d day of the month, as a number (1-31)
%H hour, 24 hour format (0-23)
%I hour, 12 hour format (1-12)
%j day of the year, as a number (1-366)
%m month as a number (1-12).
   Note: some versions of Microsoft Visual C++ may use values that range
   from 0-11.
%M minute as a number (0-59)
%p locale's equivalent of AM or PM
%Q millisecond as a number (0-999) from ver 1.1
%q microsecond as a number (0-999) from ver 1.1
%S second as a number (0-59)
%U week of the year, sunday as the first day
%w weekday as a decimal (0-6, sunday=0)
%W week of the year, monday as the first day
%x standard date string
%X standard time string
%y year in decimal, without the century (0-99)
%Y year in decimal, with the century
%Z time zone name
%% a percent sign
Parameters
fmtDatetime format

◆ setLevel()

bool RTC::Logger::setLevel ( const char *  level)

Set log level by string.

Parameters
levellog level

◆ setName()

void RTC::Logger::setName ( const char *  name)

Set suffix of date/time string of header.

Set the suffix string added after the datatime of the header.

Parameters
suffixSuffix string

◆ strToLevel()

static int RTC::Logger::strToLevel ( const char *  level)
staticprotected

Set the log level Set the log level corresponding to the given string.

◆ write() [1/2]

void RTC::Logger::write ( int  level,
const coil::Properties &  prop 
)

log output

Parameters
levellog level
propproperties

◆ write() [2/2]

void RTC::Logger::write ( int  level,
const std::string &  mes 
)
override

log output

Parameters
levellog level
mesmessage

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