NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
DetachedLogger Class Reference

This class is a specialisation of the Logger to run detached, i.e. as a global instance usable form everywhere. More...

#include <logger.hpp>

Inheritance diagram for DetachedLogger:
Collaboration diagram for DetachedLogger:

Public Member Functions

 DetachedLogger (Logger::LogLevel lvl=Logger::LVL_INFO)
 DetachedLogger constructor. Sets the default logging level. More...
 
 ~DetachedLogger ()
 DetachedLogger destructor. Appends a terminating message to the current logfile (if any). More...
 
bool is_buffering () const
 Determine, whether this instance is currently buffering or directly writing to a file. More...
 
bool open (const std::string &sLogFile)
 Open the log file and push the buffered messages directly to this file. More...
 
void setLoggingLevel (Logger::LogLevel lvl)
 Change the logging level or completely disable the logger. More...
 
void push_info (const std::string &sInfo)
 Push a message to the logger, which is not dependend on the logging level and will be shown without a timestamp. More...
 
void write_system_information ()
 A helper function to write the current OS's information to the log file. More...
 
void push_line (Logger::LogLevel lvl, const std::string &sMessage)
 Push a message with the corresponding logging level to the logger. The message will be prefixed with the millisecond-precise timestamp. More...
 
void debug (const std::string &sMessage)
 Convenience member function. More...
 
void info (const std::string &sMessage)
 Convenience member function. More...
 
void cmdline (const std::string &sMessage)
 Convenience member function. More...
 
void warning (const std::string &sMessage)
 Convenience member function. More...
 
void error (const std::string &sMessage)
 Convenience member function. More...
 
- Public Member Functions inherited from Logger
 Logger ()
 Empty default constructor. More...
 
 Logger (const std::string &sLogFile)
 Generic constructor. Will open the target file, if possible. More...
 
bool open (const std::string &sLogFile)
 Open the target logging file for writing. More...
 
void close ()
 Close the logger stream. More...
 
bool is_open () const
 Check, whether the logger stream is currently open. More...
 
void push (const std::string &sMessage)
 Push a message to the logger stream. Will automatically re-open a file, if the stream had been closed. More...
 
void push_line (const std::string &sMessage)
 Push a line to the logger stream. The stream will automatically append the line termination characters. More...
 

Private Attributes

std::vector< std::string > m_buffer
 
Logger::LogLevel m_level
 

Additional Inherited Members

- Public Types inherited from Logger
enum  LogLevel {
  LVL_DEBUG , LVL_INFO , LVL_CMDLINE , LVL_WARNING ,
  LVL_ERROR , LVL_DISABLED
}
 

Detailed Description

This class is a specialisation of the Logger to run detached, i.e. as a global instance usable form everywhere.

Definition at line 69 of file logger.hpp.

Constructor & Destructor Documentation

◆ DetachedLogger()

DetachedLogger::DetachedLogger ( Logger::LogLevel  lvl = Logger::LVL_INFO)

DetachedLogger constructor. Sets the default logging level.

Parameters
lvlLogger::LogLevel

Definition at line 197 of file logger.cpp.

◆ ~DetachedLogger()

DetachedLogger::~DetachedLogger ( )

DetachedLogger destructor. Appends a terminating message to the current logfile (if any).

Definition at line 208 of file logger.cpp.

References push_info().

Here is the call graph for this function:

Member Function Documentation

◆ cmdline()

void DetachedLogger::cmdline ( const std::string &  sMessage)
inline

Convenience member function.

Parameters
sMessageconst std::string&
Returns
void

Definition at line 118 of file logger.hpp.

References Logger::LVL_CMDLINE, and push_line().

Referenced by NumeReKernel::MainLoop().

Here is the call graph for this function:

◆ debug()

void DetachedLogger::debug ( const std::string &  sMessage)
inline

◆ error()

void DetachedLogger::error ( const std::string &  sMessage)
inline

Convenience member function.

Parameters
sMessageconst std::string&
Returns
void

Definition at line 142 of file logger.hpp.

References Logger::LVL_ERROR, and push_line().

Referenced by NumeReKernel::MainLoop(), and MyApp::OnExceptionInMainLoop().

Here is the call graph for this function:

◆ info()

◆ is_buffering()

bool DetachedLogger::is_buffering ( ) const

Determine, whether this instance is currently buffering or directly writing to a file.

Returns
bool

Definition at line 223 of file logger.cpp.

References Logger::is_open().

Referenced by push_info().

Here is the call graph for this function:

◆ open()

bool DetachedLogger::open ( const std::string &  sLogFile)

Open the log file and push the buffered messages directly to this file.

Parameters
sLogFileconst std::string&
Returns
bool

Definition at line 237 of file logger.cpp.

References m_buffer, Logger::open(), and Logger::push_line().

Referenced by NumeReKernel::StartUp().

Here is the call graph for this function:

◆ push_info()

void DetachedLogger::push_info ( const std::string &  sInfo)

Push a message to the logger, which is not dependend on the logging level and will be shown without a timestamp.

Parameters
sInfoconst std::string&
Returns
void

Definition at line 276 of file logger.cpp.

References is_buffering(), m_buffer, and Logger::push_line().

Referenced by MyApp::OnInit(), push_line(), write_system_information(), and ~DetachedLogger().

Here is the call graph for this function:

◆ push_line()

void DetachedLogger::push_line ( Logger::LogLevel  lvl,
const std::string &  sMessage 
)

Push a message with the corresponding logging level to the logger. The message will be prefixed with the millisecond-precise timestamp.

Parameters
lvlLogger::LogLevel
sMessageconst std::string&
Returns
void

Definition at line 318 of file logger.cpp.

References GET_MILLISECONDS, Logger::LVL_CMDLINE, Logger::LVL_DEBUG, Logger::LVL_DISABLED, Logger::LVL_ERROR, Logger::LVL_INFO, Logger::LVL_WARNING, m_level, push_info(), sys_time_now(), and toString().

Referenced by cmdline(), debug(), error(), info(), and warning().

Here is the call graph for this function:

◆ setLoggingLevel()

void DetachedLogger::setLoggingLevel ( Logger::LogLevel  lvl)

Change the logging level or completely disable the logger.

Parameters
lvlLogger::LogLevel
Returns
void

Definition at line 261 of file logger.cpp.

References m_level.

Referenced by cmd_set(), MyApp::OnInit(), and NumeReKernel::StartUp().

◆ warning()

void DetachedLogger::warning ( const std::string &  sMessage)
inline

Convenience member function.

Parameters
sMessageconst std::string&
Returns
void

Definition at line 130 of file logger.hpp.

References Logger::LVL_WARNING, and push_line().

Referenced by NumeRe::StringParser::createStack(), NumeReKernel::issueWarning(), NumeReKernel::MainLoop(), and MyApp::OnInit().

Here is the call graph for this function:

◆ write_system_information()

void DetachedLogger::write_system_information ( )

A helper function to write the current OS's information to the log file.

Returns
void

Definition at line 292 of file logger.cpp.

References IsWow64(), push_info(), and toString().

Referenced by MyApp::OnInit().

Here is the call graph for this function:

Member Data Documentation

◆ m_buffer

std::vector<std::string> DetachedLogger::m_buffer
private

Definition at line 72 of file logger.hpp.

Referenced by open(), and push_info().

◆ m_level

Logger::LogLevel DetachedLogger::m_level
private

Definition at line 73 of file logger.hpp.

Referenced by push_line(), and setLoggingLevel().


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