Bitcoin Core  0.18.99
P2P Digital Currency
Classes | Namespaces | Enumerations | Functions | Variables
logging.h File Reference
#include <fs.h>
#include <tinyformat.h>
#include <atomic>
#include <cstdint>
#include <list>
#include <mutex>
#include <string>
#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  CLogCategoryActive
 
class  BCLog::Logger
 

Namespaces

 BCLog
 

Enumerations

enum  BCLog::LogFlags : uint32_t {
  BCLog::NONE = 0, BCLog::NET = (1 << 0), BCLog::TOR = (1 << 1), BCLog::MEMPOOL = (1 << 2),
  BCLog::HTTP = (1 << 3), BCLog::BENCH = (1 << 4), BCLog::ZMQ = (1 << 5), BCLog::DB = (1 << 6),
  BCLog::RPC = (1 << 7), BCLog::ESTIMATEFEE = (1 << 8), BCLog::ADDRMAN = (1 << 9), BCLog::SELECTCOINS = (1 << 10),
  BCLog::REINDEX = (1 << 11), BCLog::CMPCTBLOCK = (1 << 12), BCLog::RAND = (1 << 13), BCLog::PRUNE = (1 << 14),
  BCLog::PROXY = (1 << 15), BCLog::MEMPOOLREJ = (1 << 16), BCLog::LIBEVENT = (1 << 17), BCLog::COINDB = (1 << 18),
  BCLog::QT = (1 << 19), BCLog::LEVELDB = (1 << 20), BCLog::ALL = ~(uint32_t)0
}
 

Functions

BCLog::LoggerLogInstance ()
 
static bool LogAcceptCategory (BCLog::LogFlags category)
 Return true if log accepts specified category. More...
 
std::string ListLogCategories ()
 Returns a string with the log categories. More...
 
std::vector< CLogCategoryActiveListActiveLogCategories ()
 Returns a vector of the active log categories. More...
 
bool GetLogCategory (BCLog::LogFlags &flag, const std::string &str)
 Return true if str parses as a log category and set the flag. More...
 
template<typename... Args>
static void LogPrintf (const char *fmt, const Args &... args)
 
template<typename... Args>
static void LogPrint (const BCLog::LogFlags &category, const Args &... args)
 

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
 
const char *const DEFAULT_DEBUGLOGFILE
 
bool fLogIPs
 

Function Documentation

◆ GetLogCategory()

bool GetLogCategory ( BCLog::LogFlags flag,
const std::string &  str 
)

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

Definition at line 157 of file logging.cpp.

Here is the caller graph for this function:

◆ ListActiveLogCategories()

std::vector<CLogCategoryActive> ListActiveLogCategories ( )

Returns a vector of the active log categories.

Definition at line 187 of file logging.cpp.

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

◆ ListLogCategories()

std::string ListLogCategories ( )

Returns a string with the log categories.

Definition at line 172 of file logging.cpp.

Here is the caller graph for this function:

◆ LogAcceptCategory()

static bool LogAcceptCategory ( BCLog::LogFlags  category)
inlinestatic

Return true if log accepts specified category.

Definition at line 125 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 LogPrintf, 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 destructor is never called, the logger and all its members must have a trivial destructor.

This method of initialization was originally introduced in ee3374234c60aba2cc4c5cd5cac1c0aefc2d817c.

Definition at line 14 of file logging.cpp.

Here is the caller graph for this function:

◆ LogPrint()

template<typename... Args>
static void LogPrint ( const BCLog::LogFlags category,
const Args &...  args 
)
inlinestatic

Definition at line 159 of file logging.h.

Here is the call graph for this function:

◆ LogPrintf()

template<typename... Args>
static void LogPrintf ( const char *  fmt,
const Args &...  args 
)
inlinestatic

Definition at line 144 of file logging.h.

Here is the call graph for this function:

Variable Documentation

◆ DEFAULT_DEBUGLOGFILE

const char* const DEFAULT_DEBUGLOGFILE

Definition at line 12 of file logging.cpp.

◆ DEFAULT_LOGIPS

const bool DEFAULT_LOGIPS = false
static

Definition at line 20 of file logging.h.

◆ DEFAULT_LOGTHREADNAMES

const bool DEFAULT_LOGTHREADNAMES = false
static

Definition at line 22 of file logging.h.

◆ DEFAULT_LOGTIMEMICROS

const bool DEFAULT_LOGTIMEMICROS = false
static

Definition at line 19 of file logging.h.

◆ DEFAULT_LOGTIMESTAMPS

const bool DEFAULT_LOGTIMESTAMPS = true
static

Definition at line 21 of file logging.h.

◆ fLogIPs

bool fLogIPs

Definition at line 35 of file logging.cpp.