mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
log: Construct global logger on first use
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
const char * const DEFAULT_DEBUGLOGFILE = "debug.log";
|
||||
|
||||
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
|
||||
@@ -17,11 +19,15 @@ const char * const DEFAULT_DEBUGLOGFILE = "debug.log";
|
||||
* 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.
|
||||
*/
|
||||
BCLog::Logger* const g_logger = new BCLog::Logger();
|
||||
static BCLog::Logger* g_logger{new BCLog::Logger()};
|
||||
return *g_logger;
|
||||
}
|
||||
|
||||
bool fLogIPs = DEFAULT_LOGIPS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user