diff options
Diffstat (limited to 'zenserver')
| -rw-r--r-- | zenserver/config.cpp | 4 | ||||
| -rw-r--r-- | zenserver/diag/logging.cpp | 47 | ||||
| -rw-r--r-- | zenserver/diag/logging.h | 10 |
3 files changed, 5 insertions, 56 deletions
diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 904e613a4..665c567cc 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -178,14 +178,14 @@ ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, Z if (result.count("help")) { - ConsoleLog().info("{}", options.help()); + zen::logging::ConsoleLog().info("{}", options.help()); exit(0); } } catch (cxxopts::OptionParseException& e) { - ConsoleLog().error("Error parsing zenserver arguments: {}\n\n{}", e.what(), options.help()); + zen::logging::ConsoleLog().error("Error parsing zenserver arguments: {}\n\n{}", e.what(), options.help()); throw; } diff --git a/zenserver/diag/logging.cpp b/zenserver/diag/logging.cpp index a5a4edfc0..796a15d01 100644 --- a/zenserver/diag/logging.cpp +++ b/zenserver/diag/logging.cpp @@ -189,6 +189,8 @@ EnableVTMode() void InitializeLogging(const ZenServerOptions& GlobalOptions) { + zen::logging::InitializeLogging(); + EnableVTMode(); std::filesystem::path LogPath = GlobalOptions.DataDir / "logs/zenserver.log"; @@ -243,48 +245,5 @@ InitializeLogging(const ZenServerOptions& GlobalOptions) void ShutdownLogging() { - spdlog::drop_all(); - spdlog::shutdown(); -} - -std::once_flag ConsoleInitFlag; -std::shared_ptr<spdlog::logger> ConLogger; - -spdlog::logger& -ConsoleLog() -{ - std::call_once(ConsoleInitFlag, [&] { - ConLogger = spdlog::stdout_color_mt("console"); - - ConLogger->set_pattern("%v"); - }); - - return *ConLogger; + zen::logging::ShutdownLogging(); } - -namespace zen::logging { - -spdlog::logger& -Default() -{ - return *spdlog::default_logger(); -} - -spdlog::logger& -Get(std::string_view Name) -{ - std::shared_ptr<spdlog::logger> Logger = spdlog::get(std::string(Name)); - if (!Logger) - { - Logger = std::make_shared<spdlog::logger>(std::string(Name), - begin(spdlog::default_logger()->sinks()), - end(spdlog::default_logger()->sinks())); - - Logger->set_level(spdlog::default_logger()->level()); - spdlog::register_logger(Logger); - } - - return *Logger; -} - -} // namespace zen::logging diff --git a/zenserver/diag/logging.h b/zenserver/diag/logging.h index bc93898ad..8df49f842 100644 --- a/zenserver/diag/logging.h +++ b/zenserver/diag/logging.h @@ -8,13 +8,3 @@ struct ZenServerOptions; void InitializeLogging(const ZenServerOptions& GlobalOptions); void ShutdownLogging(); - -spdlog::logger& ConsoleLog(); - -namespace zen::logging { - -spdlog::logger& Default(); - -spdlog::logger& Get(std::string_view Name); - -} // namespace zen::logging |