Bitcoin
Classes | Functions | Variables
logging.cpp File Reference
#include <logging.h>
#include <util/threadnames.h>
#include <util/time.h>
#include <mutex>

Classes

struct  CLogCategoryDesc
 

Functions

BCLog::LoggerLogInstance ()
 
static int FileWriteStr (const std::string &str, FILE *fp)
 
bool GetLogCategory (BCLog::LogFlags &flag, const std::string &str)
 
std::string ListLogCategories ()
 
std::vector< CLogCategoryActiveListActiveLogCategories ()
 

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

◆ GetLogCategory()

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

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

◆ ListActiveLogCategories()

std::vector<CLogCategoryActive> ListActiveLogCategories ( )

Returns a vector of the active log categories.

◆ ListLogCategories()

std::string ListLogCategories ( )

Returns a string with the log categories.

◆ 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.

Variable Documentation

◆ DEFAULT_DEBUGLOGFILE

const char* const DEFAULT_DEBUGLOGFILE = "debug.log"

◆ fLogIPs

bool fLogIPs = DEFAULT_LOGIPS

◆ 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::DB, "db"},
{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::ALL, "1"},
{BCLog::ALL, "all"},
}
Definition: logging.h:37
Definition: logging.h:39
Definition: logging.h:45
Definition: logging.h:56
Definition: logging.h:49
Definition: logging.h:35
Definition: logging.h:57
Definition: logging.h:43
Definition: logging.h:47
Definition: logging.h:40
Definition: logging.h:54
Definition: logging.h:52
Definition: logging.h:55
Definition: logging.h:48
Definition: logging.h:44
Definition: logging.h:38
Definition: logging.h:46
Definition: logging.h:41
Definition: logging.h:53
Definition: logging.h:42
Definition: logging.h:51
Definition: logging.h:36
Definition: logging.h:50