Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
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, ...)
#define LogInfo(...)
#define LogWarning(...)
#define LogError(...)
#define detail_LogIfCategoryAndLevelEnabled(category, level, ...)
#define LogDebug(category, ...)
#define LogTrace(category, ...)

Typedefs

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

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.
void util::log::Log (Entry entry)
 Send message to be logged.
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,
... )
Value:
detail_LogIfCategoryAndLevelEnabled(category, BCLog::Level::Debug, __VA_ARGS__)
#define detail_LogIfCategoryAndLevelEnabled(category, level,...)
Definition log.h:105

Definition at line 115 of file log.h.

◆ LogError

#define LogError ( ...)
Value:
LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__)
#define LogPrintLevel_(category, level, should_ratelimit,...)
Definition log.h:89

Definition at line 97 of file log.h.

◆ LogInfo

#define LogInfo ( ...)
Value:
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,
... )
Value:
LogPrintFormatInternal(SourceLocation{__func__}, category, level, should_ratelimit, __VA_ARGS__)
Like std::source_location, but allowing to override the function name.
Definition log.h:19
void LogPrintFormatInternal(SourceLocation &&source_loc, BCLog::LogFlags flag, BCLog::Level level, bool should_ratelimit, util::ConstevalFormatString< sizeof...(Args)> fmt, const Args &... args)
Definition log.h:71

Definition at line 89 of file log.h.

◆ LogTrace

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

Definition at line 116 of file log.h.

◆ LogWarning

#define LogWarning ( ...)
Value:
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: