diff options
| author | Stefan Boberg <[email protected]> | 2023-10-25 17:42:16 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-25 17:42:16 +0200 |
| commit | 1fd6883e242522d0b822baf280873ebf98fd1c51 (patch) | |
| tree | 58650cb932e4a470042a5a3534e699b39536b5f3 /src/zencore/logging.cpp | |
| parent | statsd metrics reporting (#496) (diff) | |
| download | zen-1fd6883e242522d0b822baf280873ebf98fd1c51.tar.xz zen-1fd6883e242522d0b822baf280873ebf98fd1c51.zip | |
eliminate redundant logging code (#499)
zenutil and zenserver both contain very similar logging setup code and this change aims to make them have most code in common.
* fullformatter/jsonformatter/RotatingFileSink are moved into dedicated header files in zenutil
* zenserver `InitializeLogging`/`ShutdownLogging` are renamed `InitializeServerLogging`/`InitializeServerLogging`
* these now call into the common zenutil `BeginInitializeLogging`/`FinishInitializeLogging` in addition to setting up server custom logging
* `std::filesystem::path` is now logged after stripping any `\\\\?\\` prefix for readability
Diffstat (limited to 'src/zencore/logging.cpp')
| -rw-r--r-- | src/zencore/logging.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/zencore/logging.cpp b/src/zencore/logging.cpp index ff37af368..c366df812 100644 --- a/src/zencore/logging.cpp +++ b/src/zencore/logging.cpp @@ -20,12 +20,14 @@ namespace zen::logging { spdlog::logger& Default() { + ZEN_ASSERT(TheDefaultLogger); return *TheDefaultLogger; } void SetDefault(std::shared_ptr<spdlog::logger> NewDefaultLogger) { + ZEN_ASSERT(NewDefaultLogger); spdlog::set_default_logger(NewDefaultLogger); TheDefaultLogger = spdlog::default_logger_raw(); } @@ -73,6 +75,7 @@ std::shared_ptr<spdlog::logger> TheErrorLogger; spdlog::logger* ErrorLog() { + // This may return nullptr return TheErrorLogger.get(); } @@ -93,6 +96,7 @@ ShutdownLogging() { spdlog::drop_all(); spdlog::shutdown(); + TheDefaultLogger = nullptr; } bool |