Bitcoin Core 30.99.0
P2P Digital Currency
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
log.h File Reference
#include <logging/categories.h>
#include <tinyformat.h>
#include <util/check.h>
#include <cstdint>
#include <source_location>
#include <string>
#include <string_view>
Include dependency graph for log.h:
This graph shows which files directly or indirectly include this file:

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::Entry
 

Namespaces

namespace  util
 
namespace  util::log
 
namespace  BCLog
 

Macros

#define LogPrintLevel_(category, level, should_ratelimit, ...)   LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
 
#define LogInfo(...)   LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)
 
#define LogWarning(...)   LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, /*should_ratelimit=*/true, __VA_ARGS__)
 
#define LogError(...)   LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__)
 
#define detail_LogIfCategoryAndLevelEnabled(category, level, ...)
 
#define LogDebug(category, ...)   detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Debug, __VA_ARGS__)
 
#define LogTrace(category, ...)   detail_LogIfCategoryAndLevelEnabled(category, BCLog::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::ShouldLog (Category category, Level level)
 Return whether messages with specified category and level should be logged. More...
 
void util::log::Log (Entry entry)
 Send message to be logged. More...
 
template<typename... Args>
void LogPrintFormatInternal (SourceLocation &&source_loc, BCLog::LogFlags flag, BCLog::Level level, bool should_ratelimit, util::ConstevalFormatString< sizeof...(Args)> fmt, const Args &... args)
 

Macro Definition Documentation

◆ detail_LogIfCategoryAndLevelEnabled

#define detail_LogIfCategoryAndLevelEnabled (   category,
  level,
  ... 
)
Value:
do { \
if (util::log::ShouldLog((category), (level))) { \
bool rate_limit{level >= BCLog::Level::Info}; \
Assume(!rate_limit); /*Only called with the levels below*/ \
LogPrintLevel_(category, level, rate_limit, __VA_ARGS__); \
} \
} while (0)
bool ShouldLog(Category category, Level level)
Return whether messages with specified category and level should be logged.
Definition: logging.cpp:606

Definition at line 105 of file log.h.

◆ LogDebug

#define LogDebug (   category,
  ... 
)    detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Debug, __VA_ARGS__)

Definition at line 115 of file log.h.

◆ LogError

#define LogError (   ...)    LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__)

Definition at line 97 of file log.h.

◆ LogInfo

#define LogInfo (   ...)    LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Info, /*should_ratelimit=*/true, __VA_ARGS__)

Definition at line 95 of file log.h.

◆ LogPrintLevel_

#define LogPrintLevel_ (   category,
  level,
  should_ratelimit,
  ... 
)    LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)

Definition at line 89 of file log.h.

◆ LogTrace

#define LogTrace (   category,
  ... 
)    detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Trace, __VA_ARGS__)

Definition at line 116 of file log.h.

◆ LogWarning

#define LogWarning (   ...)    LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Warning, /*should_ratelimit=*/true, __VA_ARGS__)

Definition at line 96 of file log.h.

Function Documentation

◆ LogPrintFormatInternal()

template<typename... Args>
void LogPrintFormatInternal ( SourceLocation &&  source_loc,
BCLog::LogFlags  flag,
BCLog::Level  level,
bool  should_ratelimit,
util::ConstevalFormatString< sizeof...(Args)>  fmt,
const Args &...  args 
)
inline

Definition at line 71 of file log.h.

Here is the call graph for this function: