ONPOSIX  2.0
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Logger.hpp File Reference
#include <fstream>
#include <ostream>
#include <string>
#include <sstream>
#include <sys/time.h>
#include "PosixMutex.hpp"
Include dependency graph for Logger.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Logger
 Simple logger to log messages on file and console. More...

Namespaces

namespace  onposix

Macros

#define LOG_MULTITHREAD
 Comment this line if you don't need multithread support.
#define LOG_NOLOG   0
 Log levels:
#define LOG_ERRORS   1
 Log only error messages.
#define LOG_WARNINGS   2
 Log warnings and error messages.
#define LOG_ALL   3
 Log all.
#define LOG_LEVEL_CONSOLE   LOG_WARNINGS
 Log level for console messages:
#define LOG_LEVEL_FILE   LOG_ALL
 Log level for file:
#define LOG_FILE(outputFile)
 Macro to set the file used for logging.
#define ERROR(msg)
 Macro to print error messages.
#define WARNING(msg)
 Macro to print warning messages.
#define DEBUG(msg)
 Macro to print debug messages.

Macro Definition Documentation

#define DEBUG (   msg)
Value:
{ \
std::ostringstream logger_dbg_stream__; \
logger_dbg_stream__ << "[DEBUG]\t"; \
logger_dbg_stream__ << msg; \
logger_dbg_stream__.str()); \
}

Macro to print debug messages.

Example of usage:

DEBUG("hello " << "world");

Definition at line 161 of file Logger.hpp.

#define ERROR (   msg)
Value:
{ \
std::ostringstream logger_dbg_stream__; \
logger_dbg_stream__ << "[ERROR]\t"; \
logger_dbg_stream__ << msg; \
logger_dbg_stream__.str()); \
logger_dbg_stream__.str()); \
}

Macro to print error messages.

Example of usage:

ERROR("hello " << "world");

Definition at line 98 of file Logger.hpp.

#define LOG_ALL   3

Log all.

Definition at line 37 of file Logger.hpp.

#define LOG_ERRORS   1

Log only error messages.

Definition at line 35 of file Logger.hpp.

#define LOG_FILE (   outputFile)
Value:

Macro to set the file used for logging.

Parameters
Basename of the file used for logging (e.g. "/tmp/myproject")

Example of configuration of the Logger: *

LOG_FILE("/tmp/myproject);

Definition at line 65 of file Logger.hpp.

#define LOG_LEVEL_CONSOLE   LOG_WARNINGS

Log level for console messages:

Definition at line 41 of file Logger.hpp.

#define LOG_LEVEL_FILE   LOG_ALL

Log level for file:

Definition at line 46 of file Logger.hpp.

#define LOG_MULTITHREAD

Comment this line if you don't need multithread support.

Definition at line 31 of file Logger.hpp.

#define LOG_NOLOG   0

Log levels:

No logging

Definition at line 34 of file Logger.hpp.

#define LOG_WARNINGS   2

Log warnings and error messages.

Definition at line 36 of file Logger.hpp.

#define WARNING (   msg)
Value:
{ \
std::ostringstream logger_dbg_stream__; \
logger_dbg_stream__ << "[WARNING]\t"; \
logger_dbg_stream__ << msg; \
logger_dbg_stream__.str()); \
logger_dbg_stream__.str()); \
}

Macro to print warning messages.

Example of usage:

WARNING("hello " << "world");

Definition at line 137 of file Logger.hpp.