iopc::LogWriter Class Reference
[iopccommon]

A LogWriter singleton is used to log messages for the IOPC 2 library or user application. More...

#include <trace.h>

List of all members.

Public Types

enum  MsgType {
  NONE = 0, INFO_SQL = 1, INFO = 2, WARNING = 4,
  ERROR = 8, TRACE = 16, DEBUG = 32
}
 Log message severity level (message type). More...

Public Member Functions

std::string getMsgTypeStr (MsgType msgType)
 Returns a MsgType string representation.

Static Public Member Functions

static void initInstance ()
 Initializes the LogWriter.
static void terminateInstance ()
 Terminates the LogWriter.
static LogWritergetInstance ()
 Returns the singletion instance.
static void logMsg (MsgType mask, const std::string &message)
 Logs a message.
static void logLine (MsgType mask, std::string file, unsigned int line, std::string function, const std::string &message)
 Logs a trace message. Used by tracing macros.
static void logOpen (const std::string &fileName=defaultFileName, bool append=true)
 Opens the log file.
static void logClose ()
 Closes the log file.
static void logInfo (const std::string &message)
 Logs a LogWriter::INFO message.
static void logWarning (const std::string &message)
 Logs a LogWriter::WARNING message.
static void logError (const std::string &message)
 Logs a LogWriter::ERROR message.
static void logSql (const std::string &message)
 Logs a LogWriter::INFO_SQL message.
static bool isInitialized ()
 Returns true if the LogWriter singletion is initialized.

Public Attributes

int traceMask
 Log file log message mask.
int traceMaskTTY
 Console log message mask.

Static Public Attributes

static const std::string defaultFileName = "iopc_log.txt"
 Default log file name - iopc_log.txt.
static const int defaultTraceMask = ( LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR )
 Default file log message mask.
static const int defaultTraceMaskTTY = ( LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR )
 Default console log message mask.


Detailed Description

A LogWriter singleton is used to log messages for the IOPC 2 library or user application.

LogWriter writes the logged messages to standard output and to a log file if file logging is enabled.

Logger logs messages of various severity levels. The levels are defined by the MsgType enumeration. Message can be filtered by these levels (message types) and their combinations.

Log macros in the iopccommon/trace.h file use LogWriter to write log messages.

Logging methods are thread safe.


Member Enumeration Documentation

Log message severity level (message type).

Enumerator:
NONE  Turns logging off
INFO_SQL  SQL trace messages representing SQL statements that has been sent to the underlying database.

Messages in this category are exclusively generated by the iopcdb library.

INFO  Informational message.

Can be generated by a user application.

WARNING  Warning message.

Can be generated by a user application.

ERROR  Messages generated usually as a result of an exception that prevented required operation to be finished.

Can be generated by the user application.

TRACE  Messages that trace the library execution.

Turning this filter on may result in large amount of logged messages. May be also disabled by commenting out the IOPC_TRACE macro in the iopccommon/trace.h file. Release versions of IOPC 2 should have this macro undefined.

DEBUG  Messages useful for debugging purposes.

May be also disabled by commenting out the IOPC_DEBUG macro in the iopccommon/trace.h file. Release versions of IOPC 2 should have this macro undefined.


Member Function Documentation

void iopc::LogWriter::initInstance (  )  [static]

Initializes the LogWriter.

Called by IopcCommon::init()

void iopc::LogWriter::terminateInstance (  )  [static]

Terminates the LogWriter.

Called by IopcCommon::shutdown()

static void iopc::LogWriter::logMsg ( MsgType  mask,
const std::string &  message 
) [inline, static]

Logs a message.

Parameters:
mask Message type/level
message The message

static void iopc::LogWriter::logOpen ( const std::string &  fileName = defaultFileName,
bool  append = true 
) [inline, static]

Opens the log file.

Called by IopcCommon::init()

static void iopc::LogWriter::logClose (  )  [inline, static]

Closes the log file.

Called by IopcCommon::shutdown()

static void iopc::LogWriter::logInfo ( const std::string &  message  )  [inline, static]

Logs a LogWriter::INFO message.

Parameters:
message The message

static void iopc::LogWriter::logWarning ( const std::string &  message  )  [inline, static]

Logs a LogWriter::WARNING message.

Parameters:
message The message

static void iopc::LogWriter::logError ( const std::string &  message  )  [inline, static]

Logs a LogWriter::ERROR message.

Parameters:
message The message

static void iopc::LogWriter::logSql ( const std::string &  message  )  [inline, static]

Logs a LogWriter::INFO_SQL message.

Parameters:
message The message


Member Data Documentation

const int iopc::LogWriter::defaultTraceMask = ( LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR ) [static]

const int iopc::LogWriter::defaultTraceMaskTTY = ( LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR ) [static]

Default console log message mask.

Defined as:


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

Generated on Tue Apr 14 16:46:35 2009 for IOPC 2 by  doxygen 1.5.6