NetCpp  v0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
logger.hpp File Reference
#include <fstream>
#include <ostream>
#include <string>
#include <sstream>
#include <sys/time.h>
#include <mutex>
#include <chrono>
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  log

Macros

#define LOG_LEVEL   3
#define LOGGER_MULTITHREAD
#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 __debug_stream__; \
__debug_stream__ << "[DEBUG]\t"; \
__debug_stream__ << msg; \
log::Logger::getInstance().print(__FILE__, __LINE__, \
__debug_stream__.str()); \
}

Macro to print debug messages.

Example of usage:

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

Definition at line 124 of file logger.hpp.

#define ERROR (   msg)
Value:
{ \
std::ostringstream __debug_stream__; \
__debug_stream__ << "[ERROR]\t"; \
__debug_stream__ << msg; \
log::Logger::getInstance().print(__FILE__, __LINE__, \
__debug_stream__.str()); \
}

Macro to print error messages.

Example of usage:

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

Definition at line 81 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 64 of file logger.hpp.

#define LOG_LEVEL   3

Log levels: 0: no logging 1: log only errors messages 2: log warnings and error messages 3: log debug, warning and error messages

Definition at line 48 of file logger.hpp.

#define LOGGER_MULTITHREAD

Definition at line 52 of file logger.hpp.

#define WARNING (   msg)
Value:
{ \
std::ostringstream __debug_stream__; \
__debug_stream__ << "[WARNING]\t"; \
__debug_stream__ << msg; \
log::Logger::getInstance().print(__FILE__, __LINE__, \
__debug_stream__.str()); \
}

Macro to print warning messages.

Example of usage:

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

Definition at line 101 of file logger.hpp.