Open Lighting Architecture: Logging

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Files | Namespaces | Macros | Enumerator | Functions
Logging

## Detailed Description

The OLA logging system.

Example
  \#include <ola/Logging.h>
  // Call this once
  ola::InitLogging(ola::OLA_LOG_WARN, ola::OLA_LOG_STDERR);
  OLA_FATAL << "Null pointer!";
  OLA_WARN << "Could not connect to server: " << ip_address;
  OLA_INFO << "Reading configs from " << config_dir;
  OLA_DEBUG << "Counter was " << counter;
  OLA_INFO
  #define OLA_INFO
  Definition Logging.h:81
  ola::OLA_LOG_WARN
  @ OLA_LOG_WARN
  Definition Logging.h:101
  OLA_DEBUG
  #define OLA_DEBUG
  Definition Logging.h:89
  OLA_FATAL
  #define OLA_FATAL
  Definition Logging.h:65
  OLA_WARN
  #define OLA_WARN
  Definition Logging.h:73
  ola::OLA_LOG_STDERR
  @ OLA_LOG_STDERR
  Definition Logging.h:117
  ola::InitLogging
  bool InitLogging(log_level level, log_output output)
  Initialize the OLA logging system.
  Definition Logging.cpp:118
  ola
  The namespace containing all OLA symbols.
  Definition Credentials.cpp:44

## Files
file | Logging.cpp
file | Logging.h
| Header file for OLA Logging.

## Namespaces
namespace | ola
| The namespace containing all OLA symbols.

## Macros
#define | OLA_LOG(level)
#define | OLA_FATAL OLA_LOG(ola::OLA_LOG_FATAL)
#define | OLA_WARN OLA_LOG(ola::OLA_LOG_WARN)
#define | OLA_INFO OLA_LOG(ola::OLA_LOG_INFO)
#define | OLA_DEBUG OLA_LOG(ola::OLA_LOG_DEBUG)

## Functions
void | ola::SetLogLevel (log_level level)
| Set the logging level.
void | ola::IncrementLogLevel ()
| Increment the log level by one. The log level wraps to OLA_LOG_NONE.
bool | ola::InitLoggingFromFlags ()
| Initialize the OLA logging system from flags.
bool | ola::InitLogging (log_level level, log_output output)
| Initialize the OLA logging system.
void | ola::InitLogging (log_level level, LogDestination *destination)
| Initialize the OLA logging system using the specified LogDestination.
virtual | ola::LogDestination::~LogDestination ()
| Destructor.
virtual void | ola::LogDestination::Write (log_level level, const std::string &log_line)=0
| An abstract function for writing to your log destination.
void | ola::StdErrorLogDestination::Write (log_level level, const std::string &log_line)
| Writes a messages out to stderr.
virtual | ola::SyslogDestination::~SyslogDestination ()
| Destructor.
virtual bool | ola::SyslogDestination::Init ()=0
| Initialize the SyslogDestination.
virtual void | ola::SyslogDestination::Write (log_level level, const std::string &log_line)=0
| Write a line to the system logger.
bool | ola::UnixSyslogDestination::Init ()
| Initialize the UnixSyslogDestination.
void | ola::UnixSyslogDestination::Write (log_level level, const std::string &log_line)
| Write a line to syslog.
log_level | ola::LogLevel ()
| Fetch the current level of logging.

## Macro Definition Documentation

## ◆ OLA_DEBUG

#define OLA_DEBUG OLA_LOG(ola::OLA_LOG_DEBUG)

Provide a stream to log a debug message.

OLA_DEBUG << "Counter was " << counter;

## ◆ OLA_FATAL

#define OLA_FATAL OLA_LOG(ola::OLA_LOG_FATAL)

Provide a stream to log a fatal message. e.g.

OLA_FATAL << "Null pointer!";

## ◆ OLA_INFO

#define OLA_INFO OLA_LOG(ola::OLA_LOG_INFO)

Provide a stream to log an informational message.

OLA_INFO << "Reading configs from " << config_dir;

## ◆ OLA_LOG

#define OLA_LOG | ( |  | level | ) |

Value:
(level <= ola::LogLevel()) && \
ola::LogLine(__FILE__, __LINE__, level).stream()
ola::LogLevel
log_level LogLevel()
Fetch the current level of logging.
Definition Logging.h:247

Provide a stream interface to log a message at the specified log level. Rather than calling this directly use one of the OLA_FATAL, OLA_WARN, OLA_INFO or OLA_DEBUG macros.

Parameters

  level | the log_level to log at.

## ◆ OLA_WARN

#define OLA_WARN OLA_LOG(ola::OLA_LOG_WARN)

Provide a stream to log a warning message.

OLA_WARN << "Could not connect to server: " << ip_address;

## Function Documentation

## ◆ Init() [1/2]

virtual bool ola::SyslogDestination::Init | ( |  | ) |
| pure virtual

Initialize the SyslogDestination.

Implemented in ola::UnixSyslogDestination.

## ◆ Init() [2/2]

bool ola::UnixSyslogDestination::Init | ( |  | ) |
| virtual

Initialize the UnixSyslogDestination.

Implements ola::SyslogDestination.

## ◆ InitLogging() [1/2]

bool ola::InitLogging | ( | log_level | level,
|  | log_output | output )

Initialize the OLA logging system.

Parameters

  level | the level to log at
  output | the destination for the logs

Returns
  true if logging was initialized successfully, false otherwise.

## ◆ InitLogging() [2/2]

void ola::InitLogging | ( | log_level | level,
|  | LogDestination * | destination )

Initialize the OLA logging system using the specified LogDestination.

Parameters

  level | the level to log at
  destination | the LogDestination to use.

## ◆ InitLoggingFromFlags()

bool ola::InitLoggingFromFlags | ( |  | ) |

Initialize the OLA logging system from flags.

Precondition
  ParseFlags() must have been called before calling this.

Returns
  true if logging was initialized successfully, false otherwise.

## ◆ LogLevel()

log_level ola::LogLevel | ( |  | ) |
| inline

Fetch the current level of logging.

Returns
  the current log_level.

## ◆ SetLogLevel()

void ola::SetLogLevel | ( | log_level | level | ) |

Set the logging level.

Parameters

  level | the new log_level to use.

## ◆ Write() [1/4]

virtual void ola::LogDestination::Write | ( | log_level | level,
|  | const std::string & | log_line )
| pure virtual

An abstract function for writing to your log destination.

Note
  You must over load this if you want to create a new log destination

Implemented in ola::StdErrorLogDestination, ola::SyslogDestination, and ola::UnixSyslogDestination.

## ◆ Write() [2/4]

void ola::StdErrorLogDestination::Write | ( | log_level | level,
|  | const std::string & | log_line )
| virtual

Writes a messages out to stderr.

Implements ola::LogDestination.

## ◆ Write() [3/4]

virtual void ola::SyslogDestination::Write | ( | log_level | level,
|  | const std::string & | log_line )
| pure virtual

Write a line to the system logger.

Note
  This is syslog on *nix or the event log on windows.

Implements ola::LogDestination.

Implemented in ola::UnixSyslogDestination.

## ◆ Write() [4/4]

void ola::UnixSyslogDestination::Write | ( | log_level | level,
|  | const std::string & | log_line )
| virtual

Write a line to syslog.

Implements ola::SyslogDestination.