Bitcoin Core 30.99.0
P2P Digital Currency
Classes | Namespaces | Functions | Variables
logging.h File Reference
#include <crypto/siphash.h>
#include <logging/categories.h>
#include <threadsafety.h>
#include <util/fs.h>
#include <util/log.h>
#include <util/string.h>
#include <util/time.h>
#include <atomic>
#include <cstdint>
#include <cstring>
#include <functional>
#include <list>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
Include dependency graph for logging.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SourceLocationEqual
 
struct  SourceLocationHasher
 
struct  LogCategory
 
class  BCLog::LogRateLimiter
 Fixed window rate limiter for logging. More...
 
struct  BCLog::LogRateLimiter::Stats
 Keeps track of an individual source location and how many available bytes are left for logging from it. More...
 
class  BCLog::Logger
 
struct  BCLog::Logger::BufferedLog
 

Namespaces

namespace  BCLog
 

Functions

BCLog::LoggerLogInstance ()
 
static bool LogAcceptCategory (BCLog::LogFlags category, BCLog::Level level)
 Return true if log accepts specified category, at the specified level. More...
 
bool GetLogCategory (BCLog::LogFlags &flag, std::string_view str)
 Return true if str parses as a log category and set the flag. More...
 

Variables

static const bool DEFAULT_LOGTIMEMICROS = false
 
static const bool DEFAULT_LOGIPS = false
 
static const bool DEFAULT_LOGTIMESTAMPS = true
 
static const bool DEFAULT_LOGTHREADNAMES = false
 
static const bool DEFAULT_LOGSOURCELOCATIONS = false
 
static constexpr bool DEFAULT_LOGLEVELALWAYS = false
 
const char *const DEFAULT_DEBUGLOGFILE
 
bool fLogIPs
 
constexpr auto BCLog::DEFAULT_LOG_LEVEL {Level::Debug}
 
constexpr size_t BCLog::DEFAULT_MAX_LOG_BUFFER {1'000'000}
 
constexpr uint64_t BCLog::RATELIMIT_MAX_BYTES {1024 * 1024}
 
constexpr auto BCLog::RATELIMIT_WINDOW {1h}
 
constexpr bool BCLog::DEFAULT_LOGRATELIMIT {true}
 

Function Documentation

◆ GetLogCategory()

bool GetLogCategory ( BCLog::LogFlags flag,
std::string_view  str 
)

Return true if str parses as a log category and set the flag.

Definition at line 220 of file logging.cpp.

Here is the caller graph for this function:

◆ LogAcceptCategory()

static bool LogAcceptCategory ( BCLog::LogFlags  category,
BCLog::Level  level 
)
inlinestatic

Return true if log accepts specified category, at the specified level.

Definition at line 294 of file logging.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogInstance()

BCLog::Logger & LogInstance ( )

NOTE: the logger instances is leaked on exit. This is ugly, but will be cleaned up by the OS/libc. Defining a logger as a global object doesn't work since the order of destruction of static/global objects is undefined. Consider if the logger gets destroyed, and then some later destructor calls LogInfo, maybe indirectly, and you get a core dump at shutdown trying to access the logger. When the shutdown sequence is fully audited and tested, explicit destruction of these objects can be implemented by changing this from a raw pointer to a std::unique_ptr. Since the ~Logger() destructor is never called, the Logger class and all its subclasses must have implicitly-defined destructors.

This method of initialization was originally introduced in ee3374234c60aba2cc4c5cd5cac1c0aefc2d817c.

Definition at line 26 of file logging.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ DEFAULT_DEBUGLOGFILE

const char* const DEFAULT_DEBUGLOGFILE
extern

Definition at line 23 of file logging.cpp.

◆ DEFAULT_LOGIPS

const bool DEFAULT_LOGIPS = false
static

Definition at line 28 of file logging.h.

◆ DEFAULT_LOGLEVELALWAYS

constexpr bool DEFAULT_LOGLEVELALWAYS = false
staticconstexpr

Definition at line 32 of file logging.h.

◆ DEFAULT_LOGSOURCELOCATIONS

const bool DEFAULT_LOGSOURCELOCATIONS = false
static

Definition at line 31 of file logging.h.

◆ DEFAULT_LOGTHREADNAMES

const bool DEFAULT_LOGTHREADNAMES = false
static

Definition at line 30 of file logging.h.

◆ DEFAULT_LOGTIMEMICROS

const bool DEFAULT_LOGTIMEMICROS = false
static

Definition at line 27 of file logging.h.

◆ DEFAULT_LOGTIMESTAMPS

const bool DEFAULT_LOGTIMESTAMPS = true
static

Definition at line 29 of file logging.h.

◆ fLogIPs

bool fLogIPs
extern

Definition at line 47 of file logging.cpp.