Lightmetrica  0.0.1.50dbee3 (yosakoi)
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Static Public Member Functions | List of all members
Logger Class Reference

#include <logger.h>

Classes

struct  LogEntry
 

Public Types

enum  LogOutputMode {
  Signal = 1<<0, Stdout = 1<<1, Stderr = 1<<2, File = 1<<3,
  FileHtml = 1<<4, DebugOutput = 1<<5, NoFileOutput = Signal | Stdout | Stderr | DebugOutput, FileOutput = File | FileHtml
}
 
enum  LogUpdateMode { LogUpdateMode::Manual, LogUpdateMode::Immediate }
 
enum  LogLevel { LogLevel::Error, LogLevel::Warning, LogLevel::Information, LogLevel::Debug }
 

Static Public Member Functions

static boost::signals2::connection Connect_LogUpdate (const std::function< void(LogEntry *)> &func)
 
static void Reset ()
 
static void Clear ()
 
static void Error (const std::string &message, const std::string &prefix)
 
static void Warn (const std::string &message, const std::string &prefix)
 
static void Info (const std::string &message, const std::string &prefix)
 
static void Debug (const std::string &message, const std::string &prefix)
 
static int CountNoFileOutputEntries ()
 
static int CountFileOutputEntries ()
 
static void SetUpdateMode (LogUpdateMode mode)
 
static void SetOutputMode (int mode)
 
static void SetOutputFrequency (int freq)
 
static void SetOutputFrequencyForFileOutput (int freq)
 
static void SetOutputFileName (const std::string &fileName)
 
static std::string FormattedDebugInfo (const char *fileName, int line)
 
static void ProcessOutput ()
 
static bool Empty ()
 
static unsigned int Indentation ()
 
static void SetIndentation (unsigned int indentation)
 

Detailed Description

Logger. Manages log messages.

Member Enumeration Documentation

enum Logger::LogLevel
strong

Log level. The log level which associate with the message.

Enumerator
Error 

Error.

Warning 

Warning.

Information 

Information.

Debug 

Debugging (used only for the debug mode).

Output mode of the logger. Determines the way to output log entries. The mode can be selected using binary operators.

Enumerator
Signal 

Output to signal LogUpdate.

Stdout 

Output to standard output.

Stderr 

Output to standard error.

File 

Output to external file (in plane text).

FileHtml 

Output to external file (in HTML format).

DebugOutput 

Output to debug output (only for VC).

NoFileOutput 

Specifies the mode with no file output.

FileOutput 

Specifies the mode with file output.

enum Logger::LogUpdateMode
strong

Update mode of the logger. Specifies how to process the log entries.

Enumerator
Manual 

Processes the entries in ProcessOutput function.

Immediate 

Processes the entry immediately. Note that the output mode is limited to NoFileOutput.

Member Function Documentation

void Logger::Clear ( )
static

Clear log entries.

boost::signals2::connection Logger::Connect_LogUpdate ( const std::function< void(LogEntry *)> &  func)
static

Connect to LogUpdate signal. The signal is emitted when the output mode is Signal and a log entry is being processed. Note that processed entry is disposed.

Parameters
funcSlot function.
int Logger::CountFileOutputEntries ( )
static

Get number of log entries for the mode FileOutput.

Returns
Number of log entries.
int Logger::CountNoFileOutputEntries ( )
static

Get number of log entries for the mode NoFileOutput.

Returns
Number of log entries.
void Logger::Debug ( const std::string &  message,
const std::string &  prefix 
)
static

Add a debug log message.

Parameters
messageLog message.
prefixPrefix message (inserted before indentation).
bool Logger::Empty ( )
static

Check if the log queue is empty.

Return values
trueThe queue is empty.
falseThe queue is not empty.
void Logger::Error ( const std::string &  message,
const std::string &  prefix 
)
static

Add an error log message.

Parameters
messageLog message.
prefixPrefix message (inserted before indentation).
std::string Logger::FormattedDebugInfo ( const char *  fileName,
int  line 
)
static

Helper function to output formatted debug message.

Parameters
fileNameFile name.
lineLine number.
Returns
Formatted log message.
unsigned int Logger::Indentation ( )
static

Get current indentation size.

Returns
Indentation.
void Logger::Info ( const std::string &  message,
const std::string &  prefix 
)
static

Add an information log message.

Parameters
messageLog message.
prefixPrefix message (inserted before indentation).
void Logger::ProcessOutput ( )
static

Process logger. Dispatches the output process of log entries. The function must be called in the event loop.

void Logger::Reset ( )
static

Reset the logger to the initial state.

void Logger::SetIndentation ( unsigned int  indentation)
static

Set the indentation size.

Parameters
indentationIndentation.
void Logger::SetOutputFileName ( const std::string &  fileName)
static

Set output file name. The file name is used for the mode File or FileHtml. The default value is nanon.log.

Parameters
fileNameOutput file name.
void Logger::SetOutputFrequency ( int  freq)
static

Set output frequency. Set to dispatch the output process by freq milliseconds. Default value is 10.

Parameters
freqFrequency in milliseconds.
void Logger::SetOutputFrequencyForFileOutput ( int  freq)
static

Set frequency of log output for file output. Changes log output frequency by once per freq entries when the output mode is File or FileHtml. The frequency should be set relatively slow. The default value is 100.

void Logger::SetOutputMode ( int  mode)
static

Set output mode of the logger. In default the log output is redirected to the signal LogUpdate.

Parameters
modeOutput mode.
void Logger::SetUpdateMode ( LogUpdateMode  mode)
static

Set the update mode of the logger. Default value is Manual, so the function ProcessOutput must be called by regular intervals.

Parameters
modeUpdate mode.
void Logger::Warn ( const std::string &  message,
const std::string &  prefix 
)
static

Add a warning log message.

Parameters
messageLog message.
prefixPrefix message (inserted before indentation).

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