Github   Telegram
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
logging Namespace Reference

Logging macro and utilities. More...

Namespaces

namespace  stacktrace_cache
 Contains functions that cache stacktrace results.
 

Classes

struct  Hex
 Formats value in a hex mode with the fixed length representation. More...
 
struct  HexShort
 
class  LogExtra
 Extra tskv fields storage. More...
 
class  LogHelper
 
struct  Quoted
 Formats a string as quoted, escaping the '\' and '"' symbols. More...
 

Typedefs

using LoggerPtr = std::shared_ptr< impl::LoggerWithInfo >
 

Enumerations

enum class  Format {
  kTskv ,
  kLtsv ,
  kRaw
}
 Log formats. More...
 
enum class  Level {
  kTrace = 0 ,
  kDebug = 1 ,
  kInfo = 2 ,
  kWarning = 3 ,
  kError = 4 ,
  kCritical = 5 ,
  kNone = 6
}
 Log levels. More...
 

Functions

Format FormatFromString (std::string_view format_str)
 Parse Format enum from string.
 
Level LevelFromString (const std::string &)
 Converts lowercase level name to a corresponding Level, throws std::runtime_error if no matching log level found.
 
std::string ToString (Level level)
 Returns a string representation of logging level.
 
std::optional< LevelOptionalLevelFromString (const std::optional< std::string > &level_name)
 Returns std::nullopt if level_name is std::nullopt, otherwaise behaves exactly like logging::LevelFromString.
 
bool ShouldLogNospan (Level level) noexcept
 Returns true if the provided log level is greater or equal to the current log level. Note that this function does not deal with tracing::Span local log level, so the log may be actually disabled by the span.
 
bool ShouldLog (Level level) noexcept
 Returns true if the provided log level is greater or equal to the current log level and to the tracing::Span local log level. In other words, returns true if the log with level is logged.
 
Level Parse (const yaml_config::YamlConfig &value, formats::parse::To< Level >)
 
LoggerPtr DefaultLogger ()
 Returns default logger.
 
LoggerPtr DefaultLoggerOptional () noexcept
 
LoggerPtr SetDefaultLogger (LoggerPtr)
 Atomically replaces default logger and returns the old one.
 
void SetDefaultLoggerLevel (Level)
 Sets new log level for default logger.
 
void SetLoggerLevel (LoggerPtr, Level)
 
Level GetDefaultLoggerLevel ()
 Returns log level for default logger.
 
bool LoggerShouldLog (const LoggerPtr &logger, Level level)
 
Level GetLoggerLevel (const LoggerPtr &logger)
 
void LogFlush ()
 Forces flush of default logger message queue.
 
void LogFlush (LoggerPtr logger)
 Forces flush of logger message queue.
 
LogHelperoperator<< (LogHelper &lh, std::error_code ec)
 
template<typename T >
LogHelperoperator<< (LogHelper &lh, const std::atomic< T > &value)
 
template<typename T >
LogHelperoperator<< (LogHelper &lh, const T *value)
 
template<typename T >
LogHelperoperator<< (LogHelper &lh, T *value)
 
template<typename T >
LogHelperoperator<< (LogHelper &lh, const std::optional< T > &value)
 
template<class Result , class... Args>
LogHelperoperator<< (LogHelper &lh, Result(*)(Args...))
 
LogHelperoperator<< (LogHelper &lh, std::chrono::system_clock::time_point tp)
 
LogHelperoperator<< (LogHelper &lh, std::chrono::seconds value)
 
LogHelperoperator<< (LogHelper &lh, std::chrono::milliseconds value)
 
LogHelperoperator<< (LogHelper &lh, std::chrono::microseconds value)
 
LogHelperoperator<< (LogHelper &lh, std::chrono::nanoseconds value)
 
LogHelperoperator<< (LogHelper &lh, std::chrono::minutes value)
 
LogHelperoperator<< (LogHelper &lh, std::chrono::hours value)
 
LoggerPtr MakeStderrLogger (const std::string &name, Format format, Level level=Level::kInfo)
 Creates synchronous stderr logger with default tskv pattern. More...
 
LoggerPtr MakeStderrLogger (const std::string &name, Level level=Level::kInfo)
 
LoggerPtr MakeStdoutLogger (const std::string &name, Format format, Level level=Level::kInfo)
 Creates synchronous stdout logger with default tskv pattern. More...
 
LoggerPtr MakeFileLogger (const std::string &name, const std::string &path, Format format, Level level=Level::kInfo)
 Creates synchronous file logger with default tskv pattern. More...
 
LoggerPtr MakeNullLogger (const std::string &name)
 Creates a logger that drops all incoming messages. More...
 

Variables

constexpr auto kLevelMax = static_cast<int>(Level::kNone)
 

Detailed Description

Logging macro and utilities.

Typedef Documentation

◆ LoggerPtr

using logging::LoggerPtr = typedef std::shared_ptr<impl::LoggerWithInfo>

Definition at line 23 of file logger.hpp.

Enumeration Type Documentation

◆ Format

enum class logging::Format
strong

Log formats.

Definition at line 13 of file format.hpp.

◆ Level

enum class logging::Level
strong

Log levels.

Definition at line 15 of file level.hpp.

Function Documentation

◆ DefaultLoggerOptional()

LoggerPtr logging::DefaultLoggerOptional ( )
noexcept

Returns default logger or a nullptr if there are problems with memory allocation

◆ MakeFileLogger()

LoggerPtr logging::MakeFileLogger ( const std::string &  name,
const std::string &  path,
Format  format,
Level  level = Level::kInfo 
)

Creates synchronous file logger with default tskv pattern.

Parameters
namelogger name, for internal use, must be unique
pathtarget log file path
See also
components::Logging

◆ MakeNullLogger()

LoggerPtr logging::MakeNullLogger ( const std::string &  name)

Creates a logger that drops all incoming messages.

Parameters
namelogger name, for internal use, must be unique
See also
components::Logging

◆ MakeStderrLogger() [1/2]

LoggerPtr logging::MakeStderrLogger ( const std::string &  name,
Format  format,
Level  level = Level::kInfo 
)

Creates synchronous stderr logger with default tskv pattern.

Parameters
namelogger name, for internal use, must be unique
See also
components::Logging

◆ MakeStderrLogger() [2/2]

LoggerPtr logging::MakeStderrLogger ( const std::string &  name,
Level  level = Level::kInfo 
)
inline

Definition at line 32 of file logger.hpp.

◆ MakeStdoutLogger()

LoggerPtr logging::MakeStdoutLogger ( const std::string &  name,
Format  format,
Level  level = Level::kInfo 
)

Creates synchronous stdout logger with default tskv pattern.

Parameters
namelogger name, for internal use, must be unique
See also
components::Logging

◆ operator<<() [1/6]

template<typename T >
LogHelper & logging::operator<< ( LogHelper lh,
const std::atomic< T > &  value 
)

Definition at line 206 of file log_helper.hpp.

◆ operator<<() [2/6]

template<typename T >
LogHelper & logging::operator<< ( LogHelper lh,
const std::optional< T > &  value 
)

Definition at line 228 of file log_helper.hpp.

◆ operator<<() [3/6]

template<typename T >
LogHelper & logging::operator<< ( LogHelper lh,
const T *  value 
)

Definition at line 211 of file log_helper.hpp.

◆ operator<<() [4/6]

template<class Result , class... Args>
LogHelper & logging::operator<< ( LogHelper lh,
Result(*)(Args...)   
)

Definition at line 237 of file log_helper.hpp.

◆ operator<<() [5/6]

LogHelper & logging::operator<< ( LogHelper lh,
std::error_code  ec 
)
inline

Definition at line 199 of file log_helper.hpp.

◆ operator<<() [6/6]

template<typename T >
LogHelper & logging::operator<< ( LogHelper lh,
T *  value 
)

Definition at line 223 of file log_helper.hpp.

Variable Documentation

◆ kLevelMax

constexpr auto logging::kLevelMax = static_cast<int>(Level::kNone)
inlineconstexpr

Definition at line 25 of file level.hpp.