Github   Telegram
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
log.hpp File Reference

Logging helpers. More...

#include <chrono>
#include <userver/compiler/select.hpp>
#include <userver/logging/level.hpp>
#include <userver/logging/log_filepath.hpp>
#include <userver/logging/log_helper.hpp>
#include <userver/logging/logger.hpp>
+ Include dependency graph for log.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  logging
 Logging macro and utilities.
 

Macros

#define DO_LOG_TO(logger, lvl)
 Builds a stream and evaluates a message for the logger. More...
 
#define LOG(lvl)
 If lvl matches the verbosity then builds a stream and evaluates a message for the default logger. More...
 
#define LOG_TO(logger, lvl)
 If lvl matches the verbosity then builds a stream and evaluates a message for the default logger. More...
 
#define LOG_TRACE()   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. More...
 
#define LOG_DEBUG()   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. More...
 
#define LOG_INFO()   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. More...
 
#define LOG_WARNING()   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. More...
 
#define LOG_ERROR()   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. More...
 
#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. More...
 
#define LOG_TRACE_TO(logger)    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. More...
 
#define LOG_DEBUG_TO(logger)    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. More...
 
#define LOG_INFO_TO(logger)    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. More...
 
#define LOG_WARNING_TO(logger)    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. More...
 
#define LOG_ERROR_TO(logger)    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. More...
 
#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. More...
 
#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. More...
 
#define LOG_LIMITED(lvl)    LOG_LIMITED_TO(USERVER_NAMESPACE::logging::DefaultLoggerOptional(), 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. More...
 
#define LOG_LIMITED_TRACE()    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. More...
 
#define LOG_LIMITED_DEBUG()    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. More...
 
#define LOG_LIMITED_INFO()   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. More...
 
#define LOG_LIMITED_WARNING()    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. More...
 
#define LOG_LIMITED_ERROR()    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. More...
 
#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. More...
 
#define LOG_LIMITED_TRACE_TO(logger)    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. More...
 
#define LOG_LIMITED_DEBUG_TO(logger)    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. More...
 
#define LOG_LIMITED_INFO_TO(logger)    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. More...
 
#define LOG_LIMITED_WARNING_TO(logger)    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. More...
 
#define LOG_LIMITED_ERROR_TO(logger)    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. More...
 
#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. More...
 

Functions

LoggerPtr logging::DefaultLogger ()
 Returns default logger.
 
LoggerPtr logging::DefaultLoggerOptional () noexcept
 
LoggerPtr logging::SetDefaultLogger (LoggerPtr)
 Atomically replaces default logger and returns the old one.
 
void logging::SetDefaultLoggerLevel (Level)
 Sets new log level for default logger.
 
void logging::SetLoggerLevel (LoggerPtr, Level)
 
Level logging::GetDefaultLoggerLevel ()
 Returns log level for default logger.
 
bool logging::LoggerShouldLog (const LoggerPtr &logger, Level level)
 
Level logging::GetLoggerLevel (const LoggerPtr &logger)
 
void logging::LogFlush ()
 Forces flush of default logger message queue.
 
void logging::LogFlush (LoggerPtr logger)
 Forces flush of logger message queue.
 

Detailed Description

Logging helpers.

Definition in file log.hpp.

Macro Definition Documentation

◆ DO_LOG_TO

#define DO_LOG_TO (   logger,
  lvl 
)

Builds a stream and evaluates a message for the logger.

Definition at line 100 of file log.hpp.

◆ LOG

#define LOG (   lvl)

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

Definition at line 111 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 164 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 201 of file log.hpp.

◆ LOG_DEBUG

#define LOG_DEBUG ( )    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
samples/config_service/config_service.cpp.

Definition at line 144 of file log.hpp.

◆ LOG_DEBUG_TO

#define LOG_DEBUG_TO (   logger)     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 177 of file log.hpp.

◆ LOG_ERROR

#define LOG_ERROR ( )    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.

Definition at line 159 of file log.hpp.

◆ LOG_ERROR_TO

#define LOG_ERROR_TO (   logger)     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 195 of file log.hpp.

◆ LOG_INFO

#define LOG_INFO ( )    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 149 of file log.hpp.

◆ LOG_INFO_TO

#define LOG_INFO_TO (   logger)     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 183 of file log.hpp.

◆ LOG_LIMITED

#define LOG_LIMITED (   lvl)     LOG_LIMITED_TO(USERVER_NAMESPACE::logging::DefaultLoggerOptional(), 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 228 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 269 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 313 of file log.hpp.

◆ LOG_LIMITED_DEBUG

#define LOG_LIMITED_DEBUG ( )     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 242 of file log.hpp.

◆ LOG_LIMITED_DEBUG_TO

#define LOG_LIMITED_DEBUG_TO (   logger)     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 285 of file log.hpp.

◆ LOG_LIMITED_ERROR

#define LOG_LIMITED_ERROR ( )     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 262 of file log.hpp.

◆ LOG_LIMITED_ERROR_TO

#define LOG_LIMITED_ERROR_TO (   logger)     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 306 of file log.hpp.

◆ LOG_LIMITED_INFO

#define LOG_LIMITED_INFO ( )    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 249 of file log.hpp.

◆ LOG_LIMITED_INFO_TO

#define LOG_LIMITED_INFO_TO (   logger)     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 292 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 213 of file log.hpp.

◆ LOG_LIMITED_TRACE

#define LOG_LIMITED_TRACE ( )     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 235 of file log.hpp.

◆ LOG_LIMITED_TRACE_TO

#define LOG_LIMITED_TRACE_TO (   logger)     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 278 of file log.hpp.

◆ LOG_LIMITED_WARNING

#define LOG_LIMITED_WARNING ( )     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 255 of file log.hpp.

◆ LOG_LIMITED_WARNING_TO

#define LOG_LIMITED_WARNING_TO (   logger)     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 299 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 default logger.

Definition at line 131 of file log.hpp.

◆ LOG_TRACE

#define LOG_TRACE ( )    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 139 of file log.hpp.

◆ LOG_TRACE_TO

#define LOG_TRACE_TO (   logger)     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 171 of file log.hpp.

◆ LOG_WARNING

#define LOG_WARNING ( )    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 154 of file log.hpp.

◆ LOG_WARNING_TO

#define LOG_WARNING_TO (   logger)     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 189 of file log.hpp.