BCLog Class Reference

A class for managing log messages. More...

#include <BCLog.h>

Public Types

enum  LogLevel {
  debug, detail, summary, warning,
  error, nothing
}
 Enumerator for the amount of details to put into the log file. More...
 

Public Member Functions

Constructor and destructor
 BCLog ()
 Constructor. More...
 

Static Public Member Functions

Getters
static BCLog::LogLevel GetLogLevelFile ()
 Returns the minimum log level for file output. More...
 
static BCLog::LogLevel GetLogLevelScreen ()
 Returns the minimum log level for screen output. More...
 
static bool GetPrefix ()
 Returns true if the loglevel is prefixed to every message. More...
 
Setters
static void SetLogLevelFile (BCLog::LogLevel loglevel)
 Sets the minimum log level for file output. More...
 
static void SetLogLevelScreen (BCLog::LogLevel loglevel)
 Sets the minimum log level for screen output. More...
 
static void SetLogLevel (BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen)
 Sets the minimum log level for file and screen output. More...
 
static void SetLogLevel (BCLog::LogLevel loglevel)
 Sets the minimum log level for file and screen output. More...
 
static void SetPrefix (bool flag)
 Toggle if the loglevel is prefixed to every message. More...
 
Miscellaneous
static void OpenLog (const std::string &filename="log.txt", BCLog::LogLevel loglevelfile=BCLog::debug, BCLog::LogLevel loglevelscreen=BCLog::summary)
 Opens log file and sets minimum log levels for file and screen output. More...
 
static bool IsOpen ()
 
static void CloseLog ()
 Closes the log file.
 
static void Out (BCLog::LogLevel loglevelfile, BCLog::LogLevel loglevelscreen, const std::string &message)
 Writes string to the file and screen log if the log level is equal or greater than the minimum. More...
 
static void Out (const std::string &message)
 
static void Out (BCLog::LogLevel loglevel, const std::string &message)
 
static void OutError (const std::string &message)
 
static void OutWarning (const std::string &message)
 
static void OutSummary (const std::string &message)
 
static void OutDetail (const std::string &message)
 
static void OutDebug (const std::string &message)
 
static void StartupInfo ()
 Writes startup information onto screen and into a logfile.
 
static const std::string & GetVersion ()
 
static std::string ToString (BCLog::LogLevel)
 Converts a log level to a string.
 

Detailed Description

A class for managing log messages.

Author
Daniel Kollar
Kevin Kröninger
Version
1.0
Date
08.2008

This class manages log messages for printing on the screen and into a log file

Definition at line 51 of file BCLog.h.

Member Enumeration Documentation

Enumerator for the amount of details to put into the log file.

Enumerator
debug 

Print everything, including debug info.

detail 

Print all details of operation.

summary 

Print only results summary, warnings, and errors.

warning 

Print only warnings and errors.

error 

Print only errors.

nothing 

Print nothing.

Definition at line 59 of file BCLog.h.

Constructor & Destructor Documentation

BCLog::BCLog ( )

Constructor.

Definition at line 36 of file BCLog.cxx.

Member Function Documentation

static BCLog::LogLevel BCLog::GetLogLevelFile ( )
inlinestatic

Returns the minimum log level for file output.

Returns
log level

Definition at line 82 of file BCLog.h.

static BCLog::LogLevel BCLog::GetLogLevelScreen ( )
inlinestatic

Returns the minimum log level for screen output.

Returns
log level

Definition at line 88 of file BCLog.h.

static bool BCLog::GetPrefix ( )
inlinestatic

Returns true if the loglevel is prefixed to every message.

Default: true

Definition at line 94 of file BCLog.h.

static const std::string& BCLog::GetVersion ( )
inlinestatic
Returns
string containing the version number

Definition at line 186 of file BCLog.h.

static bool BCLog::IsOpen ( )
inlinestatic
Returns
true if log file is open or false if not.

Definition at line 144 of file BCLog.h.

void BCLog::OpenLog ( const std::string &  filename = "log.txt",
BCLog::LogLevel  loglevelfile = BCLog::debug,
BCLog::LogLevel  loglevelscreen = BCLog::summary 
)
static

Opens log file and sets minimum log levels for file and screen output.

Parameters
filenamelog filename
loglevelfileminimum log level for file output
loglevelscreenminimum log level for screen output

Definition at line 45 of file BCLog.cxx.

void BCLog::Out ( BCLog::LogLevel  loglevelfile,
BCLog::LogLevel  loglevelscreen,
const std::string &  message 
)
static

Writes string to the file and screen log if the log level is equal or greater than the minimum.

Parameters
loglevelfileloglevel for the current message
loglevelscreenloglevel for the current message
messagestring to write to the file and screen log

Definition at line 70 of file BCLog.cxx.

static void BCLog::SetLogLevel ( BCLog::LogLevel  loglevelfile,
BCLog::LogLevel  loglevelscreen 
)
inlinestatic

Sets the minimum log level for file and screen output.

Parameters
loglevelfilelog level for file
loglevelscreenlog level for screen

Definition at line 117 of file BCLog.h.

static void BCLog::SetLogLevel ( BCLog::LogLevel  loglevel)
inlinestatic

Sets the minimum log level for file and screen output.

Parameters
loglevellog level

Definition at line 123 of file BCLog.h.

static void BCLog::SetLogLevelFile ( BCLog::LogLevel  loglevel)
inlinestatic

Sets the minimum log level for file output.

Parameters
loglevellog level

Definition at line 104 of file BCLog.h.

static void BCLog::SetLogLevelScreen ( BCLog::LogLevel  loglevel)
inlinestatic

Sets the minimum log level for screen output.

Parameters
loglevellog level

Definition at line 110 of file BCLog.h.

static void BCLog::SetPrefix ( bool  flag)
inlinestatic

Toggle if the loglevel is prefixed to every message.

Definition at line 128 of file BCLog.h.


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