blocxx
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

namespace  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.
 
#define BLOCXX_LOG_DEBUG2(logger, message)
 Log message to logger with the Debug2 level.
 
#define BLOCXX_LOG_DEBUG(logger, message)
 Log message to logger with the Debug level.
 
#define BLOCXX_LOG_INFO(logger, message)
 Log message to logger with the Info level.
 
#define BLOCXX_LOG_WARNING(logger, message)
 Log message to logger with the Warning level.
 
#define BLOCXX_LOG_ERROR(logger, message)
 Log message to logger with the Error level.
 
#define BLOCXX_LOG_FATAL_ERROR(logger, message)
 Log message to logger with the FatalError level.
 
#define BLOCXX_LOG(logger, category, message)
 Log message to logger with the specified category.
 
#define BLOCXX_SLOG_DEBUG3(logger, message)
 Log message to logger with the Debug3 level.
 
#define BLOCXX_SLOG_DEBUG2(logger, message)
 Log message to logger with the Debug2 level.
 
#define BLOCXX_SLOG_DEBUG(logger, message)
 Log message to logger with the Debug level.
 
#define BLOCXX_SLOG_INFO(logger, message)
 Log message to logger with the Info level.
 
#define BLOCXX_SLOG_WARNING(logger, message)
 Log message to logger with the Warning level.
 
#define BLOCXX_SLOG_ERROR(logger, message)
 Log message to logger with the Error level.
 
#define BLOCXX_SLOG_FATAL_ERROR(logger, message)
 Log message to logger with the FatalError level.
 
#define BLOCXX_SLOG(logger, category, message)
 Log message to logger with the specified category.
 

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)
#define BLOCXX_LOGGER_PRETTY_FUNCTION
Definition Logger.hpp:336
static const Logger & asLogger(const Logger &lgr)
Utility functions for backward compatibility with LoggerRef and the BLOCXX_LOG macros.
Definition Logger.hpp:309

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 468 of file Logger.hpp.

◆ BLOCXX_LOG_DEBUG

#define BLOCXX_LOG_DEBUG ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_DEBUG_CATEGORY, (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)
static const GlobalString STR_DEBUG_CATEGORY
Definition Logger.hpp:95

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 381 of file Logger.hpp.

Referenced by BLOCXX_NAMESPACE::Process::~Process().

◆ BLOCXX_LOG_DEBUG2

#define BLOCXX_LOG_DEBUG2 ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_DEBUG2_CATEGORY, (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)
static const GlobalString STR_DEBUG2_CATEGORY
Definition Logger.hpp:96

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 363 of file Logger.hpp.

◆ BLOCXX_LOG_DEBUG3

#define BLOCXX_LOG_DEBUG3 ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_DEBUG3_CATEGORY, (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)
static const GlobalString STR_DEBUG3_CATEGORY
Definition Logger.hpp:97

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 345 of file Logger.hpp.

Referenced by BLOCXX_NAMESPACE::Thread::definitiveCancel().

◆ BLOCXX_LOG_ERROR

#define BLOCXX_LOG_ERROR ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_ERROR_CATEGORY, (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)
static const GlobalString STR_ERROR_CATEGORY
Definition Logger.hpp:92

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 433 of file Logger.hpp.

Referenced by BLOCXX_NAMESPACE::FileSystem::createAutoDeleteTempFile(), BLOCXX_NAMESPACE::Thread::definitiveCancel(), BLOCXX_NAMESPACE::SocketBaseImpl::disconnect(), BLOCXX_NAMESPACE::AutoDescriptorPolicy::free(), BLOCXX_NAMESPACE::Thread::threadRunner(), and BLOCXX_NAMESPACE::File::~File().

◆ BLOCXX_LOG_FATAL_ERROR

#define BLOCXX_LOG_FATAL_ERROR ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_FATAL_CATEGORY, (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)
static const GlobalString STR_FATAL_CATEGORY
Definition Logger.hpp:91

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 450 of file Logger.hpp.

◆ BLOCXX_LOG_INFO

#define BLOCXX_LOG_INFO ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_INFO_CATEGORY, (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)
static const GlobalString STR_INFO_CATEGORY
Definition Logger.hpp:94

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 399 of file Logger.hpp.

◆ BLOCXX_LOG_WARNING

#define BLOCXX_LOG_WARNING ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_WARNING_CATEGORY, (message), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
errno = err; \
} while (0)
static const GlobalString STR_WARNING_CATEGORY
Definition Logger.hpp:93

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 416 of file Logger.hpp.

◆ BLOCXX_LOGGER_PRETTY_FUNCTION

#define BLOCXX_LOGGER_PRETTY_FUNCTION   ""

Definition at line 336 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 650 of file Logger.hpp.

◆ BLOCXX_SLOG_DEBUG

#define BLOCXX_SLOG_DEBUG ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_DEBUG_CATEGORY, buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
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 535 of file Logger.hpp.

◆ BLOCXX_SLOG_DEBUG2

#define BLOCXX_SLOG_DEBUG2 ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_DEBUG2_CATEGORY, buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
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 512 of file Logger.hpp.

◆ BLOCXX_SLOG_DEBUG3

#define BLOCXX_SLOG_DEBUG3 ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_DEBUG3_CATEGORY, buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
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 489 of file Logger.hpp.

◆ BLOCXX_SLOG_ERROR

#define BLOCXX_SLOG_ERROR ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_ERROR_CATEGORY, buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
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 604 of file Logger.hpp.

◆ BLOCXX_SLOG_FATAL_ERROR

#define BLOCXX_SLOG_FATAL_ERROR ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_FATAL_CATEGORY, buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
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 626 of file Logger.hpp.

◆ BLOCXX_SLOG_INFO

#define BLOCXX_SLOG_INFO ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_INFO_CATEGORY, buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
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 558 of file Logger.hpp.

◆ BLOCXX_SLOG_WARNING

#define BLOCXX_SLOG_WARNING ( logger,
message )
Value:
do \
{ \
int err = errno; \
{ \
OStringStream buf; \
buf << message; \
::BLOCXX_NAMESPACE::Logger::asLogger((logger)).logMessage(::BLOCXX_NAMESPACE::Logger::STR_WARNING_CATEGORY, buf.toString(), __FILE__, __LINE__, BLOCXX_LOGGER_PRETTY_FUNCTION); \
} \
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 581 of file Logger.hpp.