blocxx
Classes | Namespaces | Macros | Functions
Logger.hpp File Reference
#include "blocxx/BLOCXX_config.h"
#include "blocxx/CommonFwd.hpp"
#include "blocxx/String.hpp"
#include "blocxx/LogLevel.hpp"
#include "blocxx/IntrusiveCountableBase.hpp"
#include "blocxx/Exception.hpp"
#include "blocxx/LogAppender.hpp"
#include "blocxx/GlobalString.hpp"
#include <cerrno>

Go to the source code of this file.

Classes

class  BLOCXX_NAMESPACE::LoggerException
 
class  BLOCXX_NAMESPACE::Logger
 Logging interface. More...
 

Namespaces

 BLOCXX_NAMESPACE
 Taken from RFC 1321.
 

Macros

#define BLOCXX_LOGGER_PRETTY_FUNCTION   ""
 
#define BLOCXX_LOG_DEBUG3(logger, message)
 Log message to logger with the Debug3 level. More...
 
#define BLOCXX_LOG_DEBUG2(logger, message)
 Log message to logger with the Debug2 level. More...
 
#define BLOCXX_LOG_DEBUG(logger, message)
 Log message to logger with the Debug level. More...
 
#define BLOCXX_LOG_INFO(logger, message)
 Log message to logger with the Info level. More...
 
#define BLOCXX_LOG_WARNING(logger, message)
 Log message to logger with the Warning level. More...
 
#define BLOCXX_LOG_ERROR(logger, message)
 Log message to logger with the Error level. More...
 
#define BLOCXX_LOG_FATAL_ERROR(logger, message)
 Log message to logger with the FatalError level. More...
 
#define BLOCXX_LOG(logger, category, message)
 Log message to logger with the specified category. More...
 
#define BLOCXX_SLOG_DEBUG3(logger, message)
 Log message to logger with the Debug3 level. More...
 
#define BLOCXX_SLOG_DEBUG2(logger, message)
 Log message to logger with the Debug2 level. More...
 
#define BLOCXX_SLOG_DEBUG(logger, message)
 Log message to logger with the Debug level. More...
 
#define BLOCXX_SLOG_INFO(logger, message)
 Log message to logger with the Info level. More...
 
#define BLOCXX_SLOG_WARNING(logger, message)
 Log message to logger with the Warning level. More...
 
#define BLOCXX_SLOG_ERROR(logger, message)
 Log message to logger with the Error level. More...
 
#define BLOCXX_SLOG_FATAL_ERROR(logger, message)
 Log message to logger with the FatalError level. More...
 
#define BLOCXX_SLOG(logger, category, message)
 Log message to logger with the specified category. More...
 

Functions

 BLOCXX_NAMESPACE::BLOCXX_EXPORT_TEMPLATE (BLOCXX_COMMON_API, IntrusiveReference, Logger)
 

Macro Definition Documentation

◆ BLOCXX_LOG

#define BLOCXX_LOG (   logger,
  category,
  message 
)
Value:
do \
{ \
int err = errno; \
if (::BLOCXX_NAMESPACE::Logger::asLogger((logger)).categoryIsEnabled((category))) \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage((category), (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)

Log message to logger with the specified category.

message is only evaluated if logger->categoryIsEnabled(category) == true FILE and LINE are logged.

Parameters
loggerThe logger to use.
categoryThe message category
messageAn expression that evaluates to a String which will be logged.

Definition at line 469 of file Logger.hpp.

◆ BLOCXX_LOG_DEBUG

#define BLOCXX_LOG_DEBUG (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
} \
errno = err; \
} while (0)

Log message to logger with the Debug level.

message is only evaluated if logger->getLogLevel() >= E_DEBUG_LEVEL FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageAn expression that evaluates to a String which will be logged.

Definition at line 382 of file Logger.hpp.

◆ BLOCXX_LOG_DEBUG2

#define BLOCXX_LOG_DEBUG2 (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
} \
errno = err; \
} while (0)

Log message to logger with the Debug2 level.

message is only evaluated if logger->getLogLevel() >= E_DEBUG2_LEVEL FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageAn expression that evaluates to a String which will be logged.

Definition at line 364 of file Logger.hpp.

◆ BLOCXX_LOG_DEBUG3

#define BLOCXX_LOG_DEBUG3 (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
} \
errno = err; \
} while (0)

Log message to logger with the Debug3 level.

message is only evaluated if logger->getLogLevel() >= E_DEBUG3_LEVEL FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageAn expression that evaluates to a String which will be logged.

Definition at line 346 of file Logger.hpp.

◆ BLOCXX_LOG_ERROR

#define BLOCXX_LOG_ERROR (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
} \
errno = err; \
} while (0)

Log message to logger with the Error level.

message is only evaluated if logger->getLogLevel() >= E_ERROR_LEVEL FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageAn expression that evaluates to a String which will be logged.

Definition at line 434 of file Logger.hpp.

◆ BLOCXX_LOG_FATAL_ERROR

#define BLOCXX_LOG_FATAL_ERROR (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
} \
errno = err; \
} while (0)

Log message to logger with the FatalError level.

message is always evaluated. FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageAn expression that evaluates to a String which will be logged.

Definition at line 451 of file Logger.hpp.

◆ BLOCXX_LOG_INFO

#define BLOCXX_LOG_INFO (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
} \
errno = err; \
} while (0)

Log message to logger with the Info level.

message is only evaluated if logger->getLogLevel() >= E_INFO_LEVEL FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageAn expression that evaluates to a String which will be logged.

Definition at line 400 of file Logger.hpp.

◆ BLOCXX_LOG_WARNING

#define BLOCXX_LOG_WARNING (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
} \
errno = err; \
} while (0)

Log message to logger with the Warning level.

message is only evaluated if logger->getLogLevel() >= E_WARNING_LEVEL FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageAn expression that evaluates to a String which will be logged.

Definition at line 417 of file Logger.hpp.

◆ BLOCXX_LOGGER_PRETTY_FUNCTION

#define BLOCXX_LOGGER_PRETTY_FUNCTION   ""

Definition at line 337 of file Logger.hpp.

◆ BLOCXX_SLOG

#define BLOCXX_SLOG (   logger,
  category,
  message 
)
Value:
do \
{ \
int err = errno; \
if (::BLOCXX_NAMESPACE::Logger::asLogger((logger)).categoryIsEnabled((category))) \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage((category), buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)

Log message to logger with the specified category.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG(logger, "INFO", "Msg Nr" << 42);

The message parameter is only evaluated if logger->categoryIsEnabled(category) == true, FILE and LINE are logged.

Parameters
loggerThe logger to use.
categoryThe message category
messageThe message to log, using stream operator << parameters.

Definition at line 651 of file Logger.hpp.

◆ BLOCXX_SLOG_DEBUG

#define BLOCXX_SLOG_DEBUG (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
} \
errno = err; \
} while (0)

Log message to logger with the Debug level.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG_DEBUG(logger, "Msg Nr" << 42);

The message parameter is only evaluated if logger->getLogLevel() >= E_DEBUG_LEVEL, FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageThe message to log, using stream operator << parameters.

Definition at line 536 of file Logger.hpp.

◆ BLOCXX_SLOG_DEBUG2

#define BLOCXX_SLOG_DEBUG2 (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
} \
errno = err; \
} while (0)

Log message to logger with the Debug2 level.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG_DEBUG2(logger, "Msg Nr" << 42);

The message parameter is only evaluated if logger->getLogLevel() >= E_DEBUG2_LEVEL, FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageThe message to log, using stream operator << parameters.

Definition at line 513 of file Logger.hpp.

◆ BLOCXX_SLOG_DEBUG3

#define BLOCXX_SLOG_DEBUG3 (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
} \
errno = err; \
} while (0)

Log message to logger with the Debug3 level.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG_DEBUG3(logger, "Msg Nr" << 42);

The message parameter is only evaluated if logger->getLogLevel() >= E_DEBUG3_LEVEL, FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageThe message to log, using stream operator << parameters.

Definition at line 490 of file Logger.hpp.

◆ BLOCXX_SLOG_ERROR

#define BLOCXX_SLOG_ERROR (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
} \
errno = err; \
} while (0)

Log message to logger with the Error level.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG_ERROR(logger, "Msg Nr" << 42);.

The message parameter is only evaluated if logger->getLogLevel() >= E_ERROR_LEVEL, FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageThe message to log, using stream operator << parameters.

Definition at line 605 of file Logger.hpp.

◆ BLOCXX_SLOG_FATAL_ERROR

#define BLOCXX_SLOG_FATAL_ERROR (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
} \
errno = err; \
} while (0)

Log message to logger with the FatalError level.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG_FATAL_ERROR(logger, "Msg Nr" << 42);.

The message parameter is always evaluated, FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageThe message to log, using stream operator << parameters.

Definition at line 627 of file Logger.hpp.

◆ BLOCXX_SLOG_INFO

#define BLOCXX_SLOG_INFO (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
} \
errno = err; \
} while (0)

Log message to logger with the Info level.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG_INFO(logger, "Msg Nr" << 42);.

The message parameter is only evaluated if logger->getLogLevel() >= E_INFO_LEVEL, FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageThe message to log, using stream operator << parameters.

Definition at line 559 of file Logger.hpp.

◆ BLOCXX_SLOG_WARNING

#define BLOCXX_SLOG_WARNING (   logger,
  message 
)
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
} \
errno = err; \
} while (0)

Log message to logger with the Warning level.

This macro variant allows the use of a stream operator<< to construct the message, e.g. BLOCXX_SLOG_WARNING(logger, "Msg Nr" << 42);.

The message parameter is only evaluated if logger->getLogLevel() >= E_WARNING_LEVEL, FILE and LINE are logged.

Parameters
loggerThe logger to use.
messageThe message to log, using stream operator << parameters.

Definition at line 582 of file Logger.hpp.

BLOCXX_NAMESPACE::E_WARNING_LEVEL
@ E_WARNING_LEVEL
Definition: LogLevel.hpp:110
BLOCXX_NAMESPACE::Logger::asLogger
static const Logger & asLogger(const Logger &lgr)
Utility functions for backward compatibility with LoggerRef and the BLOCXX_LOG macros.
Definition: Logger.hpp:339
BLOCXX_NAMESPACE::Logger::STR_WARNING_CATEGORY
static const GlobalString STR_WARNING_CATEGORY
Definition: Logger.hpp:123
BLOCXX_LOGGER_PRETTY_FUNCTION
#define BLOCXX_LOGGER_PRETTY_FUNCTION
Definition: Logger.hpp:336
BLOCXX_NAMESPACE::E_DEBUG_LEVEL
@ E_DEBUG_LEVEL
Definition: LogLevel.hpp:112
BLOCXX_NAMESPACE::Logger::STR_INFO_CATEGORY
static const GlobalString STR_INFO_CATEGORY
Definition: Logger.hpp:124
BLOCXX_NAMESPACE::E_ERROR_LEVEL
@ E_ERROR_LEVEL
Definition: LogLevel.hpp:109
BLOCXX_NAMESPACE::E_DEBUG2_LEVEL
@ E_DEBUG2_LEVEL
Definition: LogLevel.hpp:113
BLOCXX_NAMESPACE::Logger::STR_DEBUG3_CATEGORY
static const GlobalString STR_DEBUG3_CATEGORY
Definition: Logger.hpp:127
BLOCXX_NAMESPACE::Logger::STR_FATAL_CATEGORY
static const GlobalString STR_FATAL_CATEGORY
Definition: Logger.hpp:121
BLOCXX_NAMESPACE::E_FATAL_ERROR_LEVEL
@ E_FATAL_ERROR_LEVEL
Definition: LogLevel.hpp:108
BLOCXX_NAMESPACE::Logger::STR_ERROR_CATEGORY
static const GlobalString STR_ERROR_CATEGORY
Definition: Logger.hpp:122
BLOCXX_NAMESPACE::Logger::STR_DEBUG_CATEGORY
static const GlobalString STR_DEBUG_CATEGORY
Definition: Logger.hpp:125
BLOCXX_NAMESPACE::E_DEBUG3_LEVEL
@ E_DEBUG3_LEVEL
Definition: LogLevel.hpp:114
BLOCXX_NAMESPACE::Logger::logMessage
void logMessage(const String &component, const String &category, const String &message) const
Log a message using the specified component and category The current log level is ignored.
Definition: Logger.cpp:226
BLOCXX_NAMESPACE::Logger::STR_DEBUG2_CATEGORY
static const GlobalString STR_DEBUG2_CATEGORY
Definition: Logger.hpp:126
BLOCXX_NAMESPACE::E_INFO_LEVEL
@ E_INFO_LEVEL
Definition: LogLevel.hpp:111