BLogger Class Reference

#include <BLogger.h>

List of all members.


Detailed Description

Singleton class providing logging capability.

Public Member Functions

void Close (void)
 Closes the log file.
bool EchoStdout (void) const
 Gets the indicator of whether or not to echo the output lines to std::cout.
UInt32 GetAutoFlushCount (void)
 Gets the count of messages to be written before flushing stream to disk.
ELogSeverity GetMaxSeverity (void)
 Gets the highest severity level for messages in this log.
bool IncludeTimestamp (void) const
 Gets the indicator of whether or not to prefix the timestamp on each line of the log file.
bool IsOpen (void)
 Indicates whether or not the log file is open.
bool Open (const BString &logFile, ELogSeverity maxSeverity=eLogSeverityFailure, bool appendToFile=false, bool inclTimestamp=false, bool echoStdout=false)
 Opens a log file.
void SetAutoFlushCount (UInt32 num)
 Sets the count of messages to be written before flushing stream to disk.
void SetEchoStdout (bool echo)
 Sets the indicator of whether or not to echo the output lines to std::cout.
void SetIncludeTimestamp (bool inclTimestamp)
 Sets the indicator of whether or not to prefix the timestamp on each line of the log file.
void SetMaxSeverity (ELogSeverity maxSeverity)
 Sets the highest severity level for messages in this log.
void WriteLine (ELogSeverity severity, const char *pszFormat,...)
 Writes a line to the log file.
virtual ~BLogger ()
 Destructor.

Static Public Member Functions

static void DestroyInstance (void)
 Frees the singleton instance pointer.
static BLoggerInstance (void)
 Provides access to the singleton instance of this class.
static void SetInstance (BLogger *pLogger)
 Sets the instance pointer.

Protected Member Functions

 BLogger ()
 Default constructor.
BString SeverityToString (ELogSeverity sev)
 Translates members of the ELogSeverity enumeration to BStrings.

Protected Attributes

UInt32 m_autoFlushCount
 Automatically flush stream buffers after this many messages get written to the log.
bool m_bInclTimestamp
 Indicates whether or not to include a timestamp on each line in the log file.
bool m_echoStdout
 Indicates whether or not ouput should be echoed to std::cout.
bool m_isOpen
 Indicates whether or not the log file has been opened.
BString m_logFile
 The log file's path and file name.
ELogSeverity m_maxSeverity
 The highest status to be logged.
UInt32 m_numMessages
 The number of messages that have been written to file.
QFile * m_pLog
 The log file stream.

Static Protected Attributes

static BLoggerm_instance
 The singleton instance of this class.

Constructor & Destructor Documentation

virtual ~BLogger (  )  [virtual]

Destructor.

BLogger (  )  [protected]

Default constructor.

This constructor is hidden because this is a singleton object.


Member Function Documentation

void Close ( void   ) 

Closes the log file.

static void DestroyInstance ( void   )  [static]

Frees the singleton instance pointer.

bool EchoStdout ( void   )  const [inline]

Gets the indicator of whether or not to echo the output lines to std::cout.

Returns:
True indicates that output will be echoed and false indicates that it will not be echoed.

UInt32 GetAutoFlushCount ( void   )  [inline]

Gets the count of messages to be written before flushing stream to disk.

Returns:
Number of messages written before flushing stream to disk. A return value of 0 indicates that the stream will be flushed after each message.

ELogSeverity GetMaxSeverity ( void   )  [inline]

Gets the highest severity level for messages in this log.

Messages with severity level less than or equal to this level will be written to the log.

Returns:
The maximum severity level for the log file.

bool IncludeTimestamp ( void   )  const [inline]

Gets the indicator of whether or not to prefix the timestamp on each line of the log file.

Returns:
True indicates that a timestamp will be used on each line and false indicates that a timestamp will not be used on each line.

static BLogger* Instance ( void   )  [static]

Provides access to the singleton instance of this class.

bool IsOpen ( void   )  [inline]

Indicates whether or not the log file is open.

bool Open ( const BString logFile,
ELogSeverity  maxSeverity = eLogSeverityFailure,
bool  appendToFile = false,
bool  inclTimestamp = false,
bool  echoStdout = false 
)

Opens a log file.

Parameters:
logFile The path and file name for the log file.
maxSeverity The highest severity level allowed for messages in this log. Messages with a severity level less than or equal to this value will be written to the log. In this spectrum, eLogSeverityDebug has the highest severity and eLogSeverityNone has the lowest severity.
appendToFile True indicates that messages should be appended to an existing log file and false indicates that existing messages should be overwritten.
inclTimestamp Indicates if each line of the logfile should be prefixed with a timestamp.
echoStdout Indicates if the log messages should also be writen to std::cout.
Returns:
True if the log file is successfully opened and false otherwise.

void SetAutoFlushCount ( UInt32  num  )  [inline]

Sets the count of messages to be written before flushing stream to disk.

An argument of 0 indicates that the stream will be flushed after each message.

Parameters:
num Number of messages that may be written between flushes.

void SetEchoStdout ( bool  echo  )  [inline]

Sets the indicator of whether or not to echo the output lines to std::cout.

Parameters:
echo Use true to echo the output and false otherwise.

void SetIncludeTimestamp ( bool  inclTimestamp  )  [inline]

Sets the indicator of whether or not to prefix the timestamp on each line of the log file.

Parameters:
inclTimestamp A value of true indicates that the timestamp should be included and false indicates that no timestamp should be used.

static void SetInstance ( BLogger pLogger  )  [static]

Sets the instance pointer.

This is used when passing shared BLogger object to reader/writer/transformer libraries.

Parameters:
pLogger The BLogger instance that will become the singleton instance.

void SetMaxSeverity ( ELogSeverity  maxSeverity  )  [inline]

Sets the highest severity level for messages in this log.

Messages with severity level less than or equal to this level will be written to the log.

Parameters:
maxSeverity The new maximum severity level for the log file.

BString SeverityToString ( ELogSeverity  sev  )  [protected]

Translates members of the ELogSeverity enumeration to BStrings.

Parameters:
sev The severity level.
Returns:
A BString that describes the severity level.

void WriteLine ( ELogSeverity  severity,
const char *  pszFormat,
  ... 
)

Writes a line to the log file.

Parameters:
severity Severity level for this message.
pszFormat A printf-style formatted string.


Member Data Documentation

UInt32 m_autoFlushCount [protected]

Automatically flush stream buffers after this many messages get written to the log.

A value of 0 indicates that the stream will be flushed after each message.

bool m_bInclTimestamp [protected]

Indicates whether or not to include a timestamp on each line in the log file.

bool m_echoStdout [protected]

Indicates whether or not ouput should be echoed to std::cout.

BLogger* m_instance [static, protected]

The singleton instance of this class.

bool m_isOpen [protected]

Indicates whether or not the log file has been opened.

BString m_logFile [protected]

The log file's path and file name.

ELogSeverity m_maxSeverity [protected]

The highest status to be logged.

Messages will be written to the log file if their status is less than or equal to this value.

UInt32 m_numMessages [protected]

The number of messages that have been written to file.

QFile* m_pLog [protected]

The log file stream.


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

GeoTranslate 5.0 From Blue Marble Geographics