diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-01-25 15:54:49 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-01-29 15:30:24 -0500 |
commit | 77777c5624e2f5416d85500e82b7c80e10ed01b6 (patch) | |
tree | b6f69a898835496e248bd1e5d551184e6bbf4b33 /src/logging.cpp | |
parent | d14ef5721ffcf07321704dc21f1ab9df4952a44d (diff) |
log: Construct global logger on first use
Diffstat (limited to 'src/logging.cpp')
-rw-r--r-- | src/logging.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/logging.cpp b/src/logging.cpp index 77dc2d0939..36cad6573a 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -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; |