Bitcoin Core 31.99.0
P2P Digital Currency
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
log.h File Reference
#include <logging/categories.h>
#include <tinyformat.h>
#include <util/check.h>
#include <util/threadnames.h>
#include <util/time.h>
#include <cstdint>
#include <source_location>
#include <string>
#include <string_view>
Include dependency graph for log.h:

Go to the source code of this file.

Classes

class  SourceLocation
 Like std::source_location, but allowing to override the function name. More...
 
struct  util::log::NoRateLimitTag
 Structure and constant for tagging not to rate limit. More...
 
struct  util::log::Entry
 

Namespaces

namespace  util
 
namespace  util::log
 
namespace  BCLog
 

Macros

#define detail_LogWithSrcLoc(category, level, ...)   util::log::LogPrintFormatInternal(SourceLocation{__func__}, category, level, __VA_ARGS__)
 
#define LogInfo(...)   detail_LogWithSrcLoc(BCLog::LogFlags::ALL, util::log::Level::Info, __VA_ARGS__)
 
#define LogWarning(...)   detail_LogWithSrcLoc(BCLog::LogFlags::ALL, util::log::Level::Warning, __VA_ARGS__)
 
#define LogError(...)   detail_LogWithSrcLoc(BCLog::LogFlags::ALL, util::log::Level::Error, __VA_ARGS__)
 
#define detail_LogIfCategoryAndLevelEnabled(category, shouldlog, level, ...)
 
#define LogDebug(category, ...)   detail_LogIfCategoryAndLevelEnabled(category, util::log::ShouldDebugLog, util::log::Level::Debug, __VA_ARGS__)
 
#define LogTrace(category, ...)   detail_LogIfCategoryAndLevelEnabled(category, util::log::ShouldTraceLog, util::log::Level::Trace, __VA_ARGS__)
 

Typedefs

using util::log::Category = uint64_t
 Opaque to util::log; interpreted by consumers (e.g., BCLog::LogFlags). More...
 
using BCLog::Level = util::log::Level
 Alias for compatibility. Prefer util::log::Level over BCLog::Level in new code. More...
 

Enumerations

enum class  util::log::Level {
  util::log::Trace = 0 , util::log::Debug , util::log::Info , util::log::Warning ,
  util::log::Error
}
 

Functions

bool util::log::ShouldDebugLog (Category category)
 Return whether messages with specified category should be debug logged. More...
 
bool util::log::ShouldTraceLog (Category category)
 Return whether messages with specified category should be trace logged. More...
 
void util::log::Log (Entry entry)
 Send message to be logged. More...
 
template<typename... Args>
void util::log::LogPrintFormatInternal_ (SourceLocation &&source_loc, BCLog::LogFlags flag, util::log::Level level, bool should_ratelimit, util::ConstevalFormatString< sizeof...(Args)> fmt, const Args &... args)
 
template<typename... Args>
void util::log::LogPrintFormatInternal (SourceLocation &&source_loc, BCLog::LogFlags flag, util::log::Level level, util::ConstevalFormatString< sizeof...(Args)> fmt, const Args &... args)
 
template<typename... Args>
void util::log::LogPrintFormatInternal (SourceLocation &&source_loc, BCLog::LogFlags flag, util::log::Level level, util::log::NoRateLimitTag, util::ConstevalFormatString< sizeof...(Args)> fmt, const Args &... args)
 

Variables

constexpr NoRateLimitTag util::log::NO_RATE_LIMIT {}
 

Macro Definition Documentation

◆ detail_LogIfCategoryAndLevelEnabled

#define detail_LogIfCategoryAndLevelEnabled (   category,
  shouldlog,
  level,
  ... 
)
Value:
do { \
if (shouldlog(category)) { \
detail_LogWithSrcLoc((category), (level), util::log::NO_RATE_LIMIT, __VA_ARGS__); \
} \
} while (0)
constexpr NoRateLimitTag NO_RATE_LIMIT
Definition: log.h:50

Definition at line 135 of file log.h.

◆ detail_LogWithSrcLoc

#define detail_LogWithSrcLoc (   category,
  level,
  ... 
)    util::log::LogPrintFormatInternal(SourceLocation{__func__}, category, level, __VA_ARGS__)

Definition at line 119 of file log.h.

◆ LogDebug

#define LogDebug (   category,
  ... 
)    detail_LogIfCategoryAndLevelEnabled(category, util::log::ShouldDebugLog, util::log::Level::Debug, __VA_ARGS__)

Definition at line 143 of file log.h.

◆ LogError

#define LogError (   ...)    detail_LogWithSrcLoc(BCLog::LogFlags::ALL, util::log::Level::Error, __VA_ARGS__)

Definition at line 127 of file log.h.

◆ LogInfo

#define LogInfo (   ...)    detail_LogWithSrcLoc(BCLog::LogFlags::ALL, util::log::Level::Info, __VA_ARGS__)

Definition at line 125 of file log.h.

◆ LogTrace

#define LogTrace (   category,
  ... 
)    detail_LogIfCategoryAndLevelEnabled(category, util::log::ShouldTraceLog, util::log::Level::Trace, __VA_ARGS__)

Definition at line 144 of file log.h.

◆ LogWarning

#define LogWarning (   ...)    detail_LogWithSrcLoc(BCLog::LogFlags::ALL, util::log::Level::Warning, __VA_ARGS__)

Definition at line 126 of file log.h.