userver: userver/logging/log.hpp File Reference
Loading...
Searching...
No Matches
log.hpp File Reference

Detailed Description

Logging helpers.

Definition in file log.hpp.

Go to the source code of this file.

+ This graph shows which files directly or indirectly include this file:

Classes

class  logging::DefaultLoggerGuard
 Atomically replaces the default logger. More...
 
class  logging::DefaultLoggerLevelScope
 Allows to override default log level within a scope. Primarily for use in tests. More...
 

Namespaces

namespace  logging
 Logging macro and utilities.
 

Macros

#define LOG_TO(logger, lvl)
 If lvl matches the verbosity then builds a stream and evaluates a message for the specified logger.
 
#define LOG(lvl)
 If lvl matches the verbosity then builds a stream and evaluates a message for the default logger.
 
#define LOG_TRACE()   USERVER_IMPL_LOGS_TRACE_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kTrace))
 Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kTrace.
 
#define LOG_DEBUG()   USERVER_IMPL_LOGS_DEBUG_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kDebug))
 Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kDebug.
 
#define LOG_INFO()   USERVER_IMPL_LOGS_INFO_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kInfo))
 Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kInfo.
 
#define LOG_WARNING()   USERVER_IMPL_LOGS_WARNING_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kWarning))
 Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kWarning.
 
#define LOG_ERROR()   USERVER_IMPL_LOGS_ERROR_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kError))
 Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kError.
 
#define LOG_CRITICAL()   LOG(USERVER_NAMESPACE::logging::Level::kCritical)
 Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kCritical.
 
#define LOG_TRACE_TO(logger)   USERVER_IMPL_LOGS_TRACE_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kTrace))
 Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kTrace.
 
#define LOG_DEBUG_TO(logger)   USERVER_IMPL_LOGS_DEBUG_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kDebug))
 Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kDebug.
 
#define LOG_INFO_TO(logger)   USERVER_IMPL_LOGS_INFO_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kInfo))
 Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kInfo.
 
#define LOG_WARNING_TO(logger)    USERVER_IMPL_LOGS_WARNING_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kWarning))
 Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kWarning.
 
#define LOG_ERROR_TO(logger)   USERVER_IMPL_LOGS_ERROR_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kError))
 Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kError.
 
#define LOG_CRITICAL_TO(logger)   LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kCritical)
 Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kCritical.
 
#define LOG_LIMITED_TO(logger, lvl)
 If lvl matches the verbosity then builds a stream and evaluates a message for the logger. Ignores log messages that occur too often.
 
#define LOG_LIMITED(lvl)   LOG_LIMITED_TO(USERVER_NAMESPACE::logging::GetDefaultLogger(), lvl)
 If lvl matches the verbosity then builds a stream and evaluates a message for the default logger. Ignores log messages that occur too often.
 
#define LOG_LIMITED_TRACE()   USERVER_IMPL_LOGS_TRACE_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kTrace))
 Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kTrace.
 
#define LOG_LIMITED_DEBUG()   USERVER_IMPL_LOGS_DEBUG_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kDebug))
 Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kDebug.
 
#define LOG_LIMITED_INFO()   USERVER_IMPL_LOGS_INFO_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kInfo))
 Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kInfo.
 
#define LOG_LIMITED_WARNING()   USERVER_IMPL_LOGS_WARNING_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kWarning))
 Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kWarning.
 
#define LOG_LIMITED_ERROR()   USERVER_IMPL_LOGS_ERROR_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kError))
 Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kError.
 
#define LOG_LIMITED_CRITICAL()   LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kCritical)
 Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kCritical.
 
#define LOG_LIMITED_TRACE_TO(logger)    USERVER_IMPL_LOGS_TRACE_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kTrace))
 Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kTrace.
 
#define LOG_LIMITED_DEBUG_TO(logger)    USERVER_IMPL_LOGS_DEBUG_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kDebug))
 Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kDebug.
 
#define LOG_LIMITED_INFO_TO(logger)    USERVER_IMPL_LOGS_INFO_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kInfo))
 Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kInfo.
 
#define LOG_LIMITED_WARNING_TO(logger)    USERVER_IMPL_LOGS_WARNING_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kWarning))
 Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kWarning.
 
#define LOG_LIMITED_ERROR_TO(logger)    USERVER_IMPL_LOGS_ERROR_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kError))
 Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kError.
 
#define LOG_LIMITED_CRITICAL_TO(logger)   LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kCritical)
 Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kCritical.
 

Functions

LoggerRef logging::GetDefaultLogger () noexcept
 Returns the default logger previously set by SetDefaultLogger. If the logger was not set - returns a logger that does no logging.
 
void logging::SetDefaultLoggerLevel (Level)
 Sets new log level for the default logger.
 
Level logging::GetDefaultLoggerLevel () noexcept
 Returns log level for the default logger.
 
bool logging::ShouldLog (Level level) noexcept
 
void logging::SetLoggerLevel (LoggerRef, Level)
 Sets new log level for a logger.
 
bool logging::LoggerShouldLog (LoggerRef logger, Level level) noexcept
 
bool logging::LoggerShouldLog (const LoggerPtr &logger, Level level) noexcept
 
Level logging::GetLoggerLevel (LoggerRef logger) noexcept
 
void logging::LogFlush ()
 Forces flush of default logger message queue.
 
void logging::LogFlush (LoggerRef logger)
 Forces flush of logger message queue.
 

Macro Definition Documentation

◆ LOG

#define LOG ( lvl)

If lvl matches the verbosity then builds a stream and evaluates a message for the default logger.

Definition at line 250 of file log.hpp.

◆ LOG_CRITICAL

#define LOG_CRITICAL ( )    LOG(USERVER_NAMESPACE::logging::Level::kCritical)

Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kCritical.

Definition at line 280 of file log.hpp.

◆ LOG_CRITICAL_TO

#define LOG_CRITICAL_TO ( logger)    LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kCritical)

Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kCritical.

Definition at line 313 of file log.hpp.

◆ LOG_DEBUG

#define LOG_DEBUG ( )    USERVER_IMPL_LOGS_DEBUG_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kDebug))

Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kDebug.

Examples
postgresql/functional_tests/basic_chaos/postgres_service.cpp, samples/config_service/config_service.cpp, and samples/grpc_service/src/greeter_client.cpp.

Definition at line 260 of file log.hpp.

◆ LOG_DEBUG_TO

#define LOG_DEBUG_TO ( logger)    USERVER_IMPL_LOGS_DEBUG_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kDebug))

Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kDebug.

Definition at line 292 of file log.hpp.

◆ LOG_ERROR

#define LOG_ERROR ( )    USERVER_IMPL_LOGS_ERROR_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kError))

Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kError.

Examples
samples/config_service/config_service.cpp, and samples/grpc_middleware_service/src/middlewares/server/middleware.cpp.

Definition at line 275 of file log.hpp.

◆ LOG_ERROR_TO

#define LOG_ERROR_TO ( logger)    USERVER_IMPL_LOGS_ERROR_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kError))

Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kError.

Definition at line 308 of file log.hpp.

◆ LOG_INFO

#define LOG_INFO ( )    USERVER_IMPL_LOGS_INFO_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kInfo))

Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kInfo.

Examples
samples/tcp_full_duplex_service/tcp_full_duplex_service.cpp, and samples/testsuite-support/src/logcapture.cpp.

Definition at line 265 of file log.hpp.

◆ LOG_INFO_TO

#define LOG_INFO_TO ( logger)    USERVER_IMPL_LOGS_INFO_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kInfo))

Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kInfo.

Definition at line 297 of file log.hpp.

◆ LOG_LIMITED

#define LOG_LIMITED ( lvl)    LOG_LIMITED_TO(USERVER_NAMESPACE::logging::GetDefaultLogger(), lvl)

If lvl matches the verbosity then builds a stream and evaluates a message for the default logger. Ignores log messages that occur too often.

Definition at line 338 of file log.hpp.

◆ LOG_LIMITED_CRITICAL

#define LOG_LIMITED_CRITICAL ( )    LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kCritical)

Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kCritical.

Definition at line 374 of file log.hpp.

◆ LOG_LIMITED_CRITICAL_TO

#define LOG_LIMITED_CRITICAL_TO ( logger)    LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kCritical)

Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kCritical.

Definition at line 417 of file log.hpp.

◆ LOG_LIMITED_DEBUG

#define LOG_LIMITED_DEBUG ( )    USERVER_IMPL_LOGS_DEBUG_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kDebug))

Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kDebug.

Definition at line 350 of file log.hpp.

◆ LOG_LIMITED_DEBUG_TO

#define LOG_LIMITED_DEBUG_TO ( logger)     USERVER_IMPL_LOGS_DEBUG_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kDebug))

Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kDebug.

Definition at line 389 of file log.hpp.

◆ LOG_LIMITED_ERROR

#define LOG_LIMITED_ERROR ( )    USERVER_IMPL_LOGS_ERROR_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kError))

Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kError.

Definition at line 368 of file log.hpp.

◆ LOG_LIMITED_ERROR_TO

#define LOG_LIMITED_ERROR_TO ( logger)     USERVER_IMPL_LOGS_ERROR_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kError))

Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kError.

Definition at line 410 of file log.hpp.

◆ LOG_LIMITED_INFO

#define LOG_LIMITED_INFO ( )    USERVER_IMPL_LOGS_INFO_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kInfo))

Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kInfo.

Definition at line 356 of file log.hpp.

◆ LOG_LIMITED_INFO_TO

#define LOG_LIMITED_INFO_TO ( logger)     USERVER_IMPL_LOGS_INFO_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kInfo))

Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kInfo.

Definition at line 396 of file log.hpp.

◆ LOG_LIMITED_TO

#define LOG_LIMITED_TO ( logger,
lvl )

If lvl matches the verbosity then builds a stream and evaluates a message for the logger. Ignores log messages that occur too often.

Definition at line 324 of file log.hpp.

◆ LOG_LIMITED_TRACE

#define LOG_LIMITED_TRACE ( )    USERVER_IMPL_LOGS_TRACE_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kTrace))

Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kTrace.

Definition at line 344 of file log.hpp.

◆ LOG_LIMITED_TRACE_TO

#define LOG_LIMITED_TRACE_TO ( logger)     USERVER_IMPL_LOGS_TRACE_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kTrace))

Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kTrace.

Definition at line 382 of file log.hpp.

◆ LOG_LIMITED_WARNING

#define LOG_LIMITED_WARNING ( )    USERVER_IMPL_LOGS_WARNING_ERASER(LOG_LIMITED(USERVER_NAMESPACE::logging::Level::kWarning))

Evaluates a message and logs it to the default logger if the log message does not occur too often and default logger level is below or equal to logging::Level::kWarning.

Definition at line 362 of file log.hpp.

◆ LOG_LIMITED_WARNING_TO

#define LOG_LIMITED_WARNING_TO ( logger)     USERVER_IMPL_LOGS_WARNING_ERASER(LOG_LIMITED_TO(logger, USERVER_NAMESPACE::logging::Level::kWarning))

Evaluates a message and logs it to the logger if the log message does not occur too often and logger level is below or equal to logging::Level::kWarning.

Definition at line 403 of file log.hpp.

◆ LOG_TO

#define LOG_TO ( logger,
lvl )

If lvl matches the verbosity then builds a stream and evaluates a message for the specified logger.

Definition at line 238 of file log.hpp.

◆ LOG_TRACE

#define LOG_TRACE ( )    USERVER_IMPL_LOGS_TRACE_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kTrace))

Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kTrace.

Definition at line 255 of file log.hpp.

◆ LOG_TRACE_TO

#define LOG_TRACE_TO ( logger)    USERVER_IMPL_LOGS_TRACE_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kTrace))

Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kTrace.

Definition at line 287 of file log.hpp.

◆ LOG_WARNING

#define LOG_WARNING ( )    USERVER_IMPL_LOGS_WARNING_ERASER(LOG(USERVER_NAMESPACE::logging::Level::kWarning))

Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kWarning.

Definition at line 270 of file log.hpp.

◆ LOG_WARNING_TO

#define LOG_WARNING_TO ( logger)     USERVER_IMPL_LOGS_WARNING_ERASER(LOG_TO(logger, USERVER_NAMESPACE::logging::Level::kWarning))

Evaluates a message and logs it to the logger if its level is below or equal to logging::Level::kWarning.

Definition at line 302 of file log.hpp.