#include <BLogger.h>
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 BLogger * | Instance (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 BLogger * | m_instance |
| The singleton instance of this class. | |
| virtual ~BLogger | ( | ) | [virtual] |
Destructor.
| BLogger | ( | ) | [protected] |
Default constructor.
This constructor is hidden because this is a singleton object.
| 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.
| UInt32 GetAutoFlushCount | ( | void | ) | [inline] |
Gets the count of messages to be written before flushing stream to disk.
| 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.
| bool IncludeTimestamp | ( | void | ) | const [inline] |
Gets the indicator of whether or not to prefix the timestamp on each line of the log file.
| 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.
| 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. |
| 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.
| 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.
| 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.
| 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] |
| 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.
| maxSeverity | The new maximum severity level for the log file. |
| BString SeverityToString | ( | ELogSeverity | sev | ) | [protected] |
Translates members of the ELogSeverity enumeration to BStrings.
| sev | The severity level. |
| void WriteLine | ( | ELogSeverity | severity, | |
| const char * | pszFormat, | |||
| ... | ||||
| ) |
Writes a line to the log file.
| severity | Severity level for this message. | |
| pszFormat | A printf-style formatted string. |
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.
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.