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

namespace | log4cplus
namespace | log4cplus::detail

## Macros

#define | LOG4CPLUS_SUPPRESS_DOWHILE_WARNING()
#define | LOG4CPLUS_RESTORE_DOWHILE_WARNING()
#define | LOG4CPLUS_DOWHILE_NOTHING()
#define | LOG4CPLUS_MACRO_FUNCTION()
#define | LOG4CPLUS_MACRO_FILE()
#define | LOG4CPLUS_MACRO_FILE()
#define | LOG4CPLUS_MACRO_TRACE_LOG_LEVEL(pred)
#define | LOG4CPLUS_MACRO_DEBUG_LOG_LEVEL(pred)
#define | LOG4CPLUS_MACRO_INFO_LOG_LEVEL(pred)
#define | LOG4CPLUS_MACRO_WARN_LOG_LEVEL(pred)
#define | LOG4CPLUS_MACRO_ERROR_LOG_LEVEL(pred)
#define | LOG4CPLUS_MACRO_FATAL_LOG_LEVEL(pred)
#define | LOG4CPLUS_MACRO_LOGLEVEL_PRED(pred, logLevel)
| Dispatch to LOG4CPLUS_MACRO_LOGLEVEL_* depending on log level.
#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)
| TraceLogger to log a TRACE_LOG_LEVEL message to `logger` upon entry and exiting of a method.
#define | LOG4CPLUS_TRACE_STR(logger, logEvent)
#define | LOG4CPLUS_TRACE_FMT(logger, ...)
#define | LOG4CPLUS_DEBUG(logger, logEvent)
| DEBUG_LOG_LEVEL message to `logger`.
#define | LOG4CPLUS_DEBUG_STR(logger, logEvent)
#define | LOG4CPLUS_DEBUG_FMT(logger, ...)
#define | LOG4CPLUS_INFO(logger, logEvent)
| INFO_LOG_LEVEL message to `logger`.
#define | LOG4CPLUS_INFO_STR(logger, logEvent)
#define | LOG4CPLUS_INFO_FMT(logger, ...)
#define | LOG4CPLUS_WARN(logger, logEvent)
| WARN_LOG_LEVEL message to `logger`.
#define | LOG4CPLUS_WARN_STR(logger, logEvent)
#define | LOG4CPLUS_WARN_FMT(logger, ...)
#define | LOG4CPLUS_ERROR(logger, logEvent)
| ERROR_LOG_LEVEL message to `logger`.
#define | LOG4CPLUS_ERROR_STR(logger, logEvent)
#define | LOG4CPLUS_ERROR_FMT(logger, ...)
#define | LOG4CPLUS_FATAL(logger, logEvent)
| FATAL_LOG_LEVEL message to `logger`.
#define | LOG4CPLUS_FATAL_STR(logger, logEvent)
#define | LOG4CPLUS_FATAL_FMT(logger, ...)
#define | LOG4CPLUS_ASSERT_STRINGIFY(X)
| Helper macro for LOG4CPLUS_ASSERT() macro.
#define | LOG4CPLUS_ASSERT(logger, condition)
#define | LOG4CPLUS_ASSERT_FMT(logger, condition, ...)
#define | LOG4CPLUS_ASSERT_FORMAT(logger, condition, ...)

## 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::tostringstream & | log4cplus::detail::get_macro_body_oss ()
LOG4CPLUS_EXPORT log4cplus::helpers::snprintf_buf & | log4cplus::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:
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
if (LOG4CPLUS_UNLIKELY(! (condition))) \
LOG4CPLUS_FATAL_STR ((logger), \
LOG4CPLUS_TEXT ("failed condition: ") \
LOG4CPLUS_TEXT (LOG4CPLUS_ASSERT_STRINGIFY (condition))); \
} while (0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
LOG4CPLUS_TEXT
#define LOG4CPLUS_TEXT(STRING)
Definition clogger.h:72
LOG4CPLUS_UNLIKELY
#define LOG4CPLUS_UNLIKELY(cond)
Definition config.hxx:141
LOG4CPLUS_ASSERT_STRINGIFY
#define LOG4CPLUS_ASSERT_STRINGIFY(X)
Helper macro for LOG4CPLUS_ASSERT() macro.
Definition loggingmacros.h:389
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING
#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING()
Definition loggingmacros.h:51

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

Definition at line 393 of file loggingmacros.h.

## LOG4CPLUS_ASSERT_FMT

#define LOG4CPLUS_ASSERT_FMT | ( |  | logger,
|  |  | condition,
|  |  | ... )

Value:
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
if (! (condition)) [[unlikely]] { \
LOG4CPLUS_FATAL_FMT ((logger), __VA_ARGS__); \
} \
} while (false) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

If the condition evaluates false, this macro logs a message formatted from printf format string passed in 3rd and remaining arguments.

Definition at line 406 of file loggingmacros.h.

## LOG4CPLUS_ASSERT_FORMAT

#define LOG4CPLUS_ASSERT_FORMAT | ( |  | logger,
|  |  | condition,
|  |  | ... )

Value:
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
if (! (condition)) [[unlikely]] { \
LOG4CPLUS_FATAL_FORMAT ((logger), __VA_ARGS__); \
} \
} while (false) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

If the condition evaluates false, this macro logs a message formatted from std::format format string passed in 3rd and remaining arguments.

Definition at line 418 of file loggingmacros.h.

## LOG4CPLUS_ASSERT_STRINGIFY

#define LOG4CPLUS_ASSERT_STRINGIFY | ( |  | X | ) |

Value:
#X

Helper macro for LOG4CPLUS_ASSERT() macro.

Definition at line 389 of file loggingmacros.h.

## LOG4CPLUS_DEBUG

#define LOG4CPLUS_DEBUG | ( |  | logger,
|  |  | logEvent )

Value:
LOG4CPLUS_MACRO_BODY (logger, logEvent, DEBUG_LOG_LEVEL)
LOG4CPLUS_MACRO_BODY
#define LOG4CPLUS_MACRO_BODY(logger, logEvent, logLevel)
Definition loggingmacros.h:211

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,
|  |  | ... )

Value:
LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, __VA_ARGS__)
LOG4CPLUS_MACRO_FMT_BODY
#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel,...)
Definition loggingmacros.h:244

Definition at line 298 of file loggingmacros.h.

## LOG4CPLUS_DEBUG_STR

#define LOG4CPLUS_DEBUG_STR | ( |  | logger,
|  |  | logEvent )

Value:
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, DEBUG_LOG_LEVEL)
LOG4CPLUS_MACRO_STR_BODY
#define LOG4CPLUS_MACRO_STR_BODY(logger, logEvent, logLevel)
Definition loggingmacros.h:229

Definition at line 296 of file loggingmacros.h.

## LOG4CPLUS_DOWHILE_NOTHING

#define LOG4CPLUS_DOWHILE_NOTHING | ( |  | ) |

Value:
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { } while (0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

Definition at line 56 of file loggingmacros.h.

## LOG4CPLUS_ERROR

#define LOG4CPLUS_ERROR | ( |  | logger,
|  |  | logEvent )

Value:
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,
|  |  | ... )

Value:
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 )

Value:
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, ERROR_LOG_LEVEL)

Definition at line 356 of file loggingmacros.h.

## LOG4CPLUS_FATAL

#define LOG4CPLUS_FATAL | ( |  | logger,
|  |  | logEvent )

Value:
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,
|  |  | ... )

Value:
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 )

Value:
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, FATAL_LOG_LEVEL)

Definition at line 376 of file loggingmacros.h.

## LOG4CPLUS_INFO

#define LOG4CPLUS_INFO | ( |  | logger,
|  |  | logEvent )

Value:
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,
|  |  | ... )

Value:
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 )

Value:
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:
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
log4cplus::Logger const & _l \
= log4cplus::detail::macros_get_logger (logger); \
if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM (_log4cplus_buf); \
_log4cplus_buf << logEvent; \
log4cplus::detail::macro_forced_log (_l, \
log4cplus::logLevel, _log4cplus_buf.str(), \
LOG4CPLUS_MACRO_FILE (), __LINE__, \
LOG4CPLUS_MACRO_FUNCTION ()); \
} \
} while (0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
log4cplus::Logger
This is the central class in the log4cplus package.
Definition logger.h:71
LOG4CPLUS_MACRO_FILE
#define LOG4CPLUS_MACRO_FILE()
Definition loggingmacros.h:162
LOG4CPLUS_MACRO_FUNCTION
#define LOG4CPLUS_MACRO_FUNCTION()
Definition loggingmacros.h:144
LOG4CPLUS_MACRO_LOGLEVEL_PRED
#define LOG4CPLUS_MACRO_LOGLEVEL_PRED(pred, logLevel)
Dispatch to LOG4CPLUS_MACRO_LOGLEVEL_* depending on log level.
Definition loggingmacros.h:186
log4cplus::detail::macros_get_logger
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 | ) |

Value:
LOG4CPLUS_UNLIKELY (pred)

Definition at line 173 of file loggingmacros.h.

## LOG4CPLUS_MACRO_ERROR_LOG_LEVEL

#define LOG4CPLUS_MACRO_ERROR_LOG_LEVEL | ( |  | pred | ) |

Value:
LOG4CPLUS_LIKELY (pred)
LOG4CPLUS_LIKELY
#define LOG4CPLUS_LIKELY(cond)
Definition config.hxx:140

Definition at line 179 of file loggingmacros.h.

## LOG4CPLUS_MACRO_FATAL_LOG_LEVEL

#define LOG4CPLUS_MACRO_FATAL_LOG_LEVEL | ( |  | pred | ) |

Value:
LOG4CPLUS_LIKELY (pred)

Definition at line 181 of file loggingmacros.h.

## LOG4CPLUS_MACRO_FILE [1/2]

#define LOG4CPLUS_MACRO_FILE | ( |  | ) |

Value:
__FILE__

Definition at line 162 of file loggingmacros.h.

## LOG4CPLUS_MACRO_FILE [2/2]

#define LOG4CPLUS_MACRO_FILE | ( |  | ) |

Value:
nullptr

Definition at line 162 of file loggingmacros.h.

## LOG4CPLUS_MACRO_FMT_BODY

#define LOG4CPLUS_MACRO_FMT_BODY | ( |  | logger,
|  |  | logLevel,
|  |  | ... )

Value:
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
log4cplus::Logger const & _l \
= log4cplus::detail::macros_get_logger (logger); \
if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \
log4cplus::tchar const * _logEvent \
= _snpbuf.print (__VA_ARGS__); \
log4cplus::detail::macro_forced_log (_l, \
log4cplus::logLevel, _logEvent, \
LOG4CPLUS_MACRO_FILE (), __LINE__, \
LOG4CPLUS_MACRO_FUNCTION ()); \
} \
} while(0) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
log4cplus::tchar
char tchar
Definition tchar.h:56

Definition at line 244 of file loggingmacros.h.

## LOG4CPLUS_MACRO_FUNCTION

#define LOG4CPLUS_MACRO_FUNCTION | ( |  | ) |

Value:
nullptr

Definition at line 144 of file loggingmacros.h.

## LOG4CPLUS_MACRO_INFO_LOG_LEVEL

#define LOG4CPLUS_MACRO_INFO_LOG_LEVEL | ( |  | pred | ) |

Value:
LOG4CPLUS_LIKELY (pred)

Definition at line 175 of file loggingmacros.h.

## LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM

#define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM | ( |  | var | ) |

Value:
log4cplus::tostringstream & var \
= log4cplus::detail::get_macro_body_oss ()
log4cplus::detail::get_macro_body_oss
LOG4CPLUS_EXPORT log4cplus::tostringstream & get_macro_body_oss()
log4cplus::tostringstream
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:
log4cplus::helpers::snprintf_buf & var \
= log4cplus::detail::get_macro_body_snprintf_buf ()
log4cplus::helpers::snprintf_buf
Definition snprintf.h:43
log4cplus::detail::get_macro_body_snprintf_buf
LOG4CPLUS_EXPORT log4cplus::helpers::snprintf_buf & get_macro_body_snprintf_buf()

Definition at line 204 of file loggingmacros.h.

## LOG4CPLUS_MACRO_LOGLEVEL_PRED

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

Value:
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:
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
log4cplus::Logger const & _l \
= log4cplus::detail::macros_get_logger (logger); \
if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
log4cplus::detail::macro_forced_log (_l, \
log4cplus::logLevel, logEvent, \
LOG4CPLUS_MACRO_FILE (), __LINE__, \
LOG4CPLUS_MACRO_FUNCTION ()); \
} \
} 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 | ) |

Value:
LOG4CPLUS_UNLIKELY (pred)

Definition at line 171 of file loggingmacros.h.

## LOG4CPLUS_MACRO_WARN_LOG_LEVEL

#define LOG4CPLUS_MACRO_WARN_LOG_LEVEL | ( |  | pred | ) |

Value:
LOG4CPLUS_LIKELY (pred)

Definition at line 177 of file loggingmacros.h.

## LOG4CPLUS_RESTORE_DOWHILE_WARNING

#define LOG4CPLUS_RESTORE_DOWHILE_WARNING | ( |  | ) |

Value:
/* empty */

Definition at line 52 of file loggingmacros.h.

## LOG4CPLUS_SUPPRESS_DOWHILE_WARNING

#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING | ( |  | ) |

Value:
/* empty */

Definition at line 51 of file loggingmacros.h.

## LOG4CPLUS_TRACE

#define LOG4CPLUS_TRACE | ( |  | logger,
|  |  | logEvent )

Value:
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,
|  |  | ... )

Value:
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__, \
LOG4CPLUS_MACRO_FUNCTION ());
log4cplus::TraceLogger
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 )

Value:
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, TRACE_LOG_LEVEL)

Definition at line 275 of file loggingmacros.h.

## LOG4CPLUS_WARN

#define LOG4CPLUS_WARN | ( |  | logger,
|  |  | logEvent )

Value:
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,
|  |  | ... )

Value:
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 )

Value:
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, WARN_LOG_LEVEL)

Definition at line 336 of file loggingmacros.h.