Bitcoin Core  21.99.0
P2P Digital Currency
Classes | Namespaces | Functions | Variables
logging.cpp File Reference
#include <logging.h>
#include <util/threadnames.h>
#include <util/string.h>
#include <util/time.h>
#include <mutex>
Include dependency graph for logging.cpp:

Go to the source code of this file.

Classes

struct  CLogCategoryDesc
 

Namespaces

 BCLog
 

Functions

BCLog::LoggerLogInstance ()
 
static int FileWriteStr (const std::string &str, FILE *fp)
 
bool GetLogCategory (BCLog::LogFlags &flag, const std::string &str)
 Return true if str parses as a log category and set the flag. More...
 
std::string BCLog::LogEscapeMessage (const std::string &str)
 Belts and suspenders: make sure outgoing log messages don't contain potentially suspicious characters, such as terminal control codes. More...
 

Variables

const char *const DEFAULT_DEBUGLOGFILE = "debug.log"
 
bool fLogIPs = DEFAULT_LOGIPS
 
const CLogCategoryDesc LogCategories []
 

Function Documentation

◆ FileWriteStr()

static int FileWriteStr ( const std::string &  str,
FILE *  fp 
)
static

Definition at line 38 of file logging.cpp.

Here is the caller graph for this function:

◆ 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 164 of file logging.cpp.

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 ~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 15 of file logging.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ DEFAULT_DEBUGLOGFILE

const char* const DEFAULT_DEBUGLOGFILE = "debug.log"

Definition at line 13 of file logging.cpp.

◆ fLogIPs

bool fLogIPs = DEFAULT_LOGIPS

Definition at line 36 of file logging.cpp.

◆ LogCategories

const CLogCategoryDesc LogCategories[]
Initial value:
=
{
{BCLog::NONE, "0"},
{BCLog::NONE, "none"},
{BCLog::NET, "net"},
{BCLog::TOR, "tor"},
{BCLog::MEMPOOL, "mempool"},
{BCLog::HTTP, "http"},
{BCLog::BENCH, "bench"},
{BCLog::ZMQ, "zmq"},
{BCLog::WALLETDB, "walletdb"},
{BCLog::RPC, "rpc"},
{BCLog::ESTIMATEFEE, "estimatefee"},
{BCLog::ADDRMAN, "addrman"},
{BCLog::SELECTCOINS, "selectcoins"},
{BCLog::REINDEX, "reindex"},
{BCLog::CMPCTBLOCK, "cmpctblock"},
{BCLog::RAND, "rand"},
{BCLog::PRUNE, "prune"},
{BCLog::PROXY, "proxy"},
{BCLog::MEMPOOLREJ, "mempoolrej"},
{BCLog::LIBEVENT, "libevent"},
{BCLog::COINDB, "coindb"},
{BCLog::QT, "qt"},
{BCLog::LEVELDB, "leveldb"},
{BCLog::VALIDATION, "validation"},
{BCLog::I2P, "i2p"},
{BCLog::ALL, "1"},
{BCLog::ALL, "all"},
}

Definition at line 133 of file logging.cpp.

BCLog::ZMQ
@ ZMQ
Definition: logging.h:43
BCLog::I2P
@ I2P
Definition: logging.h:60
BCLog::HTTP
@ HTTP
Definition: logging.h:41
BCLog::BENCH
@ BENCH
Definition: logging.h:42
BCLog::ESTIMATEFEE
@ ESTIMATEFEE
Definition: logging.h:46
BCLog::PROXY
@ PROXY
Definition: logging.h:53
BCLog::PRUNE
@ PRUNE
Definition: logging.h:52
BCLog::MEMPOOLREJ
@ MEMPOOLREJ
Definition: logging.h:54
BCLog::RPC
@ RPC
Definition: logging.h:45
BCLog::WALLETDB
@ WALLETDB
Definition: logging.h:44
BCLog::LEVELDB
@ LEVELDB
Definition: logging.h:58
BCLog::LIBEVENT
@ LIBEVENT
Definition: logging.h:55
BCLog::TOR
@ TOR
Definition: logging.h:39
BCLog::REINDEX
@ REINDEX
Definition: logging.h:49
BCLog::QT
@ QT
Definition: logging.h:57
BCLog::ALL
@ ALL
Definition: logging.h:61
BCLog::VALIDATION
@ VALIDATION
Definition: logging.h:59
BCLog::RAND
@ RAND
Definition: logging.h:51
BCLog::COINDB
@ COINDB
Definition: logging.h:56
BCLog::MEMPOOL
@ MEMPOOL
Definition: logging.h:40
BCLog::SELECTCOINS
@ SELECTCOINS
Definition: logging.h:48
BCLog::ADDRMAN
@ ADDRMAN
Definition: logging.h:47
BCLog::NET
@ NET
Definition: logging.h:38
BCLog::CMPCTBLOCK
@ CMPCTBLOCK
Definition: logging.h:50
BCLog::NONE
@ NONE
Definition: logging.h:37