#include <trace.h>
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 LogWriter & | getInstance () |
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. |
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.
Log message severity level (message type).
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 |
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. |
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.
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] |
static void iopc::LogWriter::logWarning | ( | const std::string & | message | ) | [inline, static] |
static void iopc::LogWriter::logError | ( | const std::string & | message | ) | [inline, static] |
static void iopc::LogWriter::logSql | ( | const std::string & | message | ) | [inline, static] |
const int iopc::LogWriter::defaultTraceMask = ( LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR ) [static] |
Default file log message mask.
Defined as:
LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR IOPC_TRACE defined: LogWriter::INFO_SQL | LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR | LogWriter::TRACE IOPC_DEBUG defined: LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR | LogWriter::DEBUG IOPC_DEBUG and IOPC_TRACE defined: LogWriter::INFO_SQL | LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR | LogWriter::DEBUG | LogWriter::TRACE
const int iopc::LogWriter::defaultTraceMaskTTY = ( LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR ) [static] |
Default console log message mask.
Defined as:
LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR IOPC_TRACE defined: LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR IOPC_DEBUG defined: LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR | LogWriter::DEBUG IOPC_DEBUG and IOPC_TRACE defined: LogWriter::INFO | LogWriter::WARNING | LogWriter::ERROR | LogWriter::DEBUG