log4cplus  2.1.0
Namespaces | Macros | Functions
loggingmacros.h File Reference

This header defines the logging macros. More...

#include <log4cplus/config.hxx>
#include <log4cplus/streams.h>
#include <log4cplus/logger.h>
#include <log4cplus/helpers/snprintf.h>
#include <log4cplus/tracelogger.h>
#include <sstream>
#include <utility>
Include dependency graph for loggingmacros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 log4cplus
 
 log4cplus::detail
 

Macros

#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING()   /* empty */
 
#define LOG4CPLUS_RESTORE_DOWHILE_WARNING()   /* empty */
 
#define LOG4CPLUS_DOWHILE_NOTHING()
 
#define LOG4CPLUS_MACRO_FUNCTION()   nullptr
 
#define LOG4CPLUS_MACRO_FILE()   nullptr
 
#define LOG4CPLUS_MACRO_FILE()   __FILE__
 
#define LOG4CPLUS_MACRO_TRACE_LOG_LEVEL(pred)    LOG4CPLUS_UNLIKELY (pred)
 
#define LOG4CPLUS_MACRO_DEBUG_LOG_LEVEL(pred)    LOG4CPLUS_UNLIKELY (pred)
 
#define LOG4CPLUS_MACRO_INFO_LOG_LEVEL(pred)    LOG4CPLUS_LIKELY (pred)
 
#define LOG4CPLUS_MACRO_WARN_LOG_LEVEL(pred)    LOG4CPLUS_LIKELY (pred)
 
#define LOG4CPLUS_MACRO_ERROR_LOG_LEVEL(pred)    LOG4CPLUS_LIKELY (pred)
 
#define LOG4CPLUS_MACRO_FATAL_LOG_LEVEL(pred)    LOG4CPLUS_LIKELY (pred)
 
#define LOG4CPLUS_MACRO_LOGLEVEL_PRED(pred, logLevel)    LOG4CPLUS_MACRO_ ## logLevel (pred)
 Dispatch to LOG4CPLUS_MACRO_LOGLEVEL_* depending on log level. More...
 
#define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM(var)
 
#define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF(var)
 
#define LOG4CPLUS_MACRO_BODY(logger, logEvent, logLevel)
 
#define LOG4CPLUS_MACRO_STR_BODY(logger, logEvent, logLevel)
 
#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, ...)
 
#define LOG4CPLUS_TRACE_METHOD(logger, logEvent)
 
#define LOG4CPLUS_TRACE(logger, logEvent)    LOG4CPLUS_MACRO_BODY (logger, logEvent, TRACE_LOG_LEVEL)
 TraceLogger to log a TRACE_LOG_LEVEL message to logger upon entry and exiting of a method. More...
 
#define LOG4CPLUS_TRACE_STR(logger, logEvent)    LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, TRACE_LOG_LEVEL)
 
#define LOG4CPLUS_TRACE_FMT(logger, ...)    LOG4CPLUS_MACRO_FMT_BODY (logger, TRACE_LOG_LEVEL, __VA_ARGS__)
 
#define LOG4CPLUS_DEBUG(logger, logEvent)    LOG4CPLUS_MACRO_BODY (logger, logEvent, DEBUG_LOG_LEVEL)
 DEBUG_LOG_LEVEL message to logger. More...
 
#define LOG4CPLUS_DEBUG_STR(logger, logEvent)    LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, DEBUG_LOG_LEVEL)
 
#define LOG4CPLUS_DEBUG_FMT(logger, ...)    LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, __VA_ARGS__)
 
#define LOG4CPLUS_INFO(logger, logEvent)    LOG4CPLUS_MACRO_BODY (logger, logEvent, INFO_LOG_LEVEL)
 INFO_LOG_LEVEL message to logger. More...
 
#define LOG4CPLUS_INFO_STR(logger, logEvent)    LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, INFO_LOG_LEVEL)
 
#define LOG4CPLUS_INFO_FMT(logger, ...)    LOG4CPLUS_MACRO_FMT_BODY (logger, INFO_LOG_LEVEL, __VA_ARGS__)
 
#define LOG4CPLUS_WARN(logger, logEvent)    LOG4CPLUS_MACRO_BODY (logger, logEvent, WARN_LOG_LEVEL)
 WARN_LOG_LEVEL message to logger. More...
 
#define LOG4CPLUS_WARN_STR(logger, logEvent)    LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, WARN_LOG_LEVEL)
 
#define LOG4CPLUS_WARN_FMT(logger, ...)    LOG4CPLUS_MACRO_FMT_BODY (logger, WARN_LOG_LEVEL, __VA_ARGS__)
 
#define LOG4CPLUS_ERROR(logger, logEvent)    LOG4CPLUS_MACRO_BODY (logger, logEvent, ERROR_LOG_LEVEL)
 ERROR_LOG_LEVEL message to logger. More...
 
#define LOG4CPLUS_ERROR_STR(logger, logEvent)    LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, ERROR_LOG_LEVEL)
 
#define LOG4CPLUS_ERROR_FMT(logger, ...)    LOG4CPLUS_MACRO_FMT_BODY (logger, ERROR_LOG_LEVEL, __VA_ARGS__)
 
#define LOG4CPLUS_FATAL(logger, logEvent)    LOG4CPLUS_MACRO_BODY (logger, logEvent, FATAL_LOG_LEVEL)
 FATAL_LOG_LEVEL message to logger. More...
 
#define LOG4CPLUS_FATAL_STR(logger, logEvent)    LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, FATAL_LOG_LEVEL)
 
#define LOG4CPLUS_FATAL_FMT(logger, ...)    LOG4CPLUS_MACRO_FMT_BODY (logger, FATAL_LOG_LEVEL, __VA_ARGS__)
 
#define LOG4CPLUS_ASSERT_STRINGIFY(X)   #X
 Helper macro for LOG4CPLUS_ASSERT() macro. More...
 
#define LOG4CPLUS_ASSERT(logger, condition)
 If the condition given in second parameter evaluates false, this macro logs it using FATAL log level, including the condition's source text. More...
 

Functions

Logger log4cplus::detail::macros_get_logger (Logger const &logger)
 
Logger const & log4cplus::detail::macros_get_logger (Logger &logger)
 
Logger log4cplus::detail::macros_get_logger (Logger &&logger)
 
Logger log4cplus::detail::macros_get_logger (tstring const &logger)
 
Logger log4cplus::detail::macros_get_logger (tchar const *logger)
 
LOG4CPLUS_EXPORT void log4cplus::detail::clear_tostringstream (tostringstream &)
 
LOG4CPLUS_EXPORT log4cplus::tostringstreamlog4cplus::detail::get_macro_body_oss ()
 
LOG4CPLUS_EXPORT log4cplus::helpers::snprintf_buflog4cplus::detail::get_macro_body_snprintf_buf ()
 
LOG4CPLUS_EXPORT void log4cplus::detail::macro_forced_log (log4cplus::Logger const &, log4cplus::LogLevel, log4cplus::tstring const &, char const *, int, char const *)
 
LOG4CPLUS_EXPORT void log4cplus::detail::macro_forced_log (log4cplus::Logger const &, log4cplus::LogLevel, log4cplus::tchar const *, char const *, int, char const *)
 

Detailed Description

This header defines the logging macros.

Definition in file loggingmacros.h.

Macro Definition Documentation

◆ LOG4CPLUS_ASSERT

#define LOG4CPLUS_ASSERT (   logger,
  condition 
)
Value:
do { \
if (LOG4CPLUS_UNLIKELY(! (condition))) \
LOG4CPLUS_FATAL_STR ((logger), \
LOG4CPLUS_TEXT ("failed condition: ") \
} while (0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
#define LOG4CPLUS_TEXT(STRING)
Definition: clogger.h:72
#define LOG4CPLUS_UNLIKELY(cond)
Definition: config.hxx:141
#define LOG4CPLUS_ASSERT_STRINGIFY(X)
Helper macro for LOG4CPLUS_ASSERT() macro.
#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING()
Definition: loggingmacros.h:51

If the condition given in second parameter evaluates false, this macro logs it using FATAL log level, including the condition's source text.

Definition at line 394 of file loggingmacros.h.

◆ LOG4CPLUS_ASSERT_STRINGIFY

#define LOG4CPLUS_ASSERT_STRINGIFY (   X)    #X

Helper macro for LOG4CPLUS_ASSERT() macro.

Definition at line 389 of file loggingmacros.h.

◆ LOG4CPLUS_DEBUG

#define LOG4CPLUS_DEBUG (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_BODY (logger, logEvent, DEBUG_LOG_LEVEL)

DEBUG_LOG_LEVEL message to logger.

logEvent will be streamed into an ostream.

Definition at line 294 of file loggingmacros.h.

◆ LOG4CPLUS_DEBUG_FMT

#define LOG4CPLUS_DEBUG_FMT (   logger,
  ... 
)     LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, __VA_ARGS__)

Definition at line 298 of file loggingmacros.h.

◆ LOG4CPLUS_DEBUG_STR

#define LOG4CPLUS_DEBUG_STR (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, DEBUG_LOG_LEVEL)

Definition at line 296 of file loggingmacros.h.

◆ LOG4CPLUS_DOWHILE_NOTHING

#define LOG4CPLUS_DOWHILE_NOTHING ( )
Value:
do { } while (0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

Definition at line 56 of file loggingmacros.h.

◆ LOG4CPLUS_ERROR

#define LOG4CPLUS_ERROR (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_BODY (logger, logEvent, ERROR_LOG_LEVEL)

ERROR_LOG_LEVEL message to logger.

logEvent will be streamed into an ostream.

Definition at line 354 of file loggingmacros.h.

◆ LOG4CPLUS_ERROR_FMT

#define LOG4CPLUS_ERROR_FMT (   logger,
  ... 
)     LOG4CPLUS_MACRO_FMT_BODY (logger, ERROR_LOG_LEVEL, __VA_ARGS__)

Definition at line 358 of file loggingmacros.h.

◆ LOG4CPLUS_ERROR_STR

#define LOG4CPLUS_ERROR_STR (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, ERROR_LOG_LEVEL)

Definition at line 356 of file loggingmacros.h.

◆ LOG4CPLUS_FATAL

#define LOG4CPLUS_FATAL (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_BODY (logger, logEvent, FATAL_LOG_LEVEL)

FATAL_LOG_LEVEL message to logger.

logEvent will be streamed into an ostream.

Definition at line 374 of file loggingmacros.h.

◆ LOG4CPLUS_FATAL_FMT

#define LOG4CPLUS_FATAL_FMT (   logger,
  ... 
)     LOG4CPLUS_MACRO_FMT_BODY (logger, FATAL_LOG_LEVEL, __VA_ARGS__)

Definition at line 378 of file loggingmacros.h.

◆ LOG4CPLUS_FATAL_STR

#define LOG4CPLUS_FATAL_STR (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, FATAL_LOG_LEVEL)

Definition at line 376 of file loggingmacros.h.

◆ LOG4CPLUS_INFO

#define LOG4CPLUS_INFO (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_BODY (logger, logEvent, INFO_LOG_LEVEL)

INFO_LOG_LEVEL message to logger.

logEvent will be streamed into an ostream.

Definition at line 314 of file loggingmacros.h.

◆ LOG4CPLUS_INFO_FMT

#define LOG4CPLUS_INFO_FMT (   logger,
  ... 
)     LOG4CPLUS_MACRO_FMT_BODY (logger, INFO_LOG_LEVEL, __VA_ARGS__)

Definition at line 318 of file loggingmacros.h.

◆ LOG4CPLUS_INFO_STR

#define LOG4CPLUS_INFO_STR (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, INFO_LOG_LEVEL)

Definition at line 316 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_BODY

#define LOG4CPLUS_MACRO_BODY (   logger,
  logEvent,
  logLevel 
)
Value:
do { \
log4cplus::Logger const & _l \
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM (_log4cplus_buf); \
_log4cplus_buf << logEvent; \
log4cplus::logLevel, _log4cplus_buf.str(), \
LOG4CPLUS_MACRO_FILE (), __LINE__, \
} \
} while (0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
#define LOG4CPLUS_MACRO_FILE()
#define LOG4CPLUS_MACRO_FUNCTION()
#define LOG4CPLUS_MACRO_LOGLEVEL_PRED(pred, logLevel)
Dispatch to LOG4CPLUS_MACRO_LOGLEVEL_* depending on log level.
LOG4CPLUS_EXPORT void macro_forced_log(log4cplus::Logger const &, log4cplus::LogLevel, log4cplus::tchar const *, char const *, int, char const *)
Logger macros_get_logger(Logger const &logger)
Definition: loggingmacros.h:87

Definition at line 211 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_DEBUG_LOG_LEVEL

#define LOG4CPLUS_MACRO_DEBUG_LOG_LEVEL (   pred)     LOG4CPLUS_UNLIKELY (pred)

Definition at line 173 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_ERROR_LOG_LEVEL

#define LOG4CPLUS_MACRO_ERROR_LOG_LEVEL (   pred)     LOG4CPLUS_LIKELY (pred)

Definition at line 179 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_FATAL_LOG_LEVEL

#define LOG4CPLUS_MACRO_FATAL_LOG_LEVEL (   pred)     LOG4CPLUS_LIKELY (pred)

Definition at line 181 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_FILE [1/2]

#define LOG4CPLUS_MACRO_FILE ( )    nullptr

Definition at line 165 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_FILE [2/2]

#define LOG4CPLUS_MACRO_FILE ( )    __FILE__

Definition at line 165 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_FMT_BODY

#define LOG4CPLUS_MACRO_FMT_BODY (   logger,
  logLevel,
  ... 
)
Value:
do { \
log4cplus::Logger const & _l \
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \
log4cplus::tchar const * _logEvent \
= _snpbuf.print (__VA_ARGS__); \
log4cplus::logLevel, _logEvent, \
LOG4CPLUS_MACRO_FILE (), __LINE__, \
} \
} while(0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
char tchar
Definition: tchar.h:56

Definition at line 244 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_FUNCTION

#define LOG4CPLUS_MACRO_FUNCTION ( )    nullptr

Definition at line 144 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_INFO_LOG_LEVEL

#define LOG4CPLUS_MACRO_INFO_LOG_LEVEL (   pred)     LOG4CPLUS_LIKELY (pred)

Definition at line 175 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM

#define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM (   var)
Value:
LOG4CPLUS_EXPORT log4cplus::tostringstream & get_macro_body_oss()
std::basic_ostringstream< tchar > tostringstream
Definition: streams.h:42

Definition at line 200 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF

#define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (   var)
Value:

Definition at line 204 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_LOGLEVEL_PRED

#define LOG4CPLUS_MACRO_LOGLEVEL_PRED (   pred,
  logLevel 
)     LOG4CPLUS_MACRO_ ## logLevel (pred)

Dispatch to LOG4CPLUS_MACRO_LOGLEVEL_* depending on log level.

Definition at line 186 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_STR_BODY

#define LOG4CPLUS_MACRO_STR_BODY (   logger,
  logEvent,
  logLevel 
)
Value:
do { \
log4cplus::Logger const & _l \
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
log4cplus::logLevel, logEvent, \
LOG4CPLUS_MACRO_FILE (), __LINE__, \
} \
} while(0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

Definition at line 229 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_TRACE_LOG_LEVEL

#define LOG4CPLUS_MACRO_TRACE_LOG_LEVEL (   pred)     LOG4CPLUS_UNLIKELY (pred)

Definition at line 171 of file loggingmacros.h.

◆ LOG4CPLUS_MACRO_WARN_LOG_LEVEL

#define LOG4CPLUS_MACRO_WARN_LOG_LEVEL (   pred)     LOG4CPLUS_LIKELY (pred)

Definition at line 177 of file loggingmacros.h.

◆ LOG4CPLUS_RESTORE_DOWHILE_WARNING

#define LOG4CPLUS_RESTORE_DOWHILE_WARNING ( )    /* empty */

Definition at line 52 of file loggingmacros.h.

◆ LOG4CPLUS_SUPPRESS_DOWHILE_WARNING

#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING ( )    /* empty */

Definition at line 51 of file loggingmacros.h.

◆ LOG4CPLUS_TRACE

#define LOG4CPLUS_TRACE (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_BODY (logger, logEvent, TRACE_LOG_LEVEL)

TraceLogger to log a TRACE_LOG_LEVEL message to logger upon entry and exiting of a method.

logEvent will be streamed into an ostream.

Definition at line 273 of file loggingmacros.h.

◆ LOG4CPLUS_TRACE_FMT

#define LOG4CPLUS_TRACE_FMT (   logger,
  ... 
)     LOG4CPLUS_MACRO_FMT_BODY (logger, TRACE_LOG_LEVEL, __VA_ARGS__)

Definition at line 277 of file loggingmacros.h.

◆ LOG4CPLUS_TRACE_METHOD

#define LOG4CPLUS_TRACE_METHOD (   logger,
  logEvent 
)
Value:
log4cplus::TraceLogger _log4cplus_trace_logger(logger, logEvent, \
LOG4CPLUS_MACRO_FILE (), __LINE__, \
This class is used to produce "Trace" logging.
Definition: tracelogger.h:51

Definition at line 269 of file loggingmacros.h.

◆ LOG4CPLUS_TRACE_STR

#define LOG4CPLUS_TRACE_STR (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, TRACE_LOG_LEVEL)

Definition at line 275 of file loggingmacros.h.

◆ LOG4CPLUS_WARN

#define LOG4CPLUS_WARN (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_BODY (logger, logEvent, WARN_LOG_LEVEL)

WARN_LOG_LEVEL message to logger.

logEvent will be streamed into an ostream.

Definition at line 334 of file loggingmacros.h.

◆ LOG4CPLUS_WARN_FMT

#define LOG4CPLUS_WARN_FMT (   logger,
  ... 
)     LOG4CPLUS_MACRO_FMT_BODY (logger, WARN_LOG_LEVEL, __VA_ARGS__)

Definition at line 338 of file loggingmacros.h.

◆ LOG4CPLUS_WARN_STR

#define LOG4CPLUS_WARN_STR (   logger,
  logEvent 
)     LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, WARN_LOG_LEVEL)

Definition at line 336 of file loggingmacros.h.