Logging helpers.
Definition in file log.hpp.
Go to the source code of this file.
#include <chrono>
#include <userver/compiler/select.hpp>
#include <userver/logging/fwd.hpp>
#include <userver/logging/level.hpp>
#include <userver/logging/log_filepath.hpp>
#include <userver/logging/log_helper.hpp>
Classes | |
class | logging::DefaultLoggerGuard |
Atomically replaces the default logger. More... | |
class | logging::DefaultLoggerLevelScope |
Allows to override global log level for the whole service 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(...) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kTrace. | |
#define | LOG_DEBUG(...) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kDebug. | |
#define | LOG_INFO(...) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kInfo. | |
#define | LOG_WARNING(...) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kWarning. | |
#define | LOG_ERROR(...) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kError. | |
#define | LOG_CRITICAL(...) |
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, ...) |
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, ...) |
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, ...) |
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, ...) |
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, ...) |
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, ...) |
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, ...) |
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(...) |
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(...) |
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(...) |
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(...) |
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(...) |
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(...) |
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, ...) |
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, ...) |
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, ...) |
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, ...) |
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, ...) |
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, ...) |
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. | |
#define LOG | ( | lvl, | |
... ) |
#define LOG_CRITICAL | ( | ... | ) |
#define LOG_CRITICAL_TO | ( | logger, | |
... ) |
#define LOG_DEBUG | ( | ... | ) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kDebug.
#define LOG_DEBUG_TO | ( | logger, | |
... ) |
#define LOG_ERROR | ( | ... | ) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kError.
#define LOG_ERROR_TO | ( | logger, | |
... ) |
#define LOG_INFO | ( | ... | ) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kInfo.
#define LOG_INFO_TO | ( | logger, | |
... ) |
#define LOG_LIMITED | ( | 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_CRITICAL | ( | ... | ) |
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_CRITICAL_TO | ( | logger, | |
... ) |
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.
#define LOG_LIMITED_DEBUG | ( | ... | ) |
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_DEBUG_TO | ( | logger, | |
... ) |
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_ERROR | ( | ... | ) |
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_ERROR_TO | ( | logger, | |
... ) |
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_INFO | ( | ... | ) |
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_INFO_TO | ( | logger, | |
... ) |
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_TO | ( | logger, | |
lvl, | |||
... ) |
#define LOG_LIMITED_TRACE | ( | ... | ) |
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_TRACE_TO | ( | logger, | |
... ) |
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_WARNING | ( | ... | ) |
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_WARNING_TO | ( | logger, | |
... ) |
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_TO | ( | logger, | |
lvl, | |||
... ) |
#define LOG_TRACE | ( | ... | ) |
#define LOG_TRACE_TO | ( | logger, | |
... ) |
#define LOG_WARNING | ( | ... | ) |
Evaluates a message and logs it to the default logger if its level is below or equal to logging::Level::kWarning.