diff options
| author | Stefan Boberg <[email protected]> | 2021-09-08 19:10:59 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-08 19:10:59 +0200 |
| commit | f04eebe974a08922c74b28d3b08d1edc97496c47 (patch) | |
| tree | 7ced15c6aa2758d6fa52f69ecb545e743e6f4040 /zencore/logging.cpp | |
| parent | Merged from main (diff) | |
| download | zen-f04eebe974a08922c74b28d3b08d1edc97496c47.tar.xz zen-f04eebe974a08922c74b28d3b08d1edc97496c47.zip | |
Moved a bunch of logging code into zencore
Diffstat (limited to 'zencore/logging.cpp')
| -rw-r--r-- | zencore/logging.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/zencore/logging.cpp b/zencore/logging.cpp new file mode 100644 index 000000000..89d588650 --- /dev/null +++ b/zencore/logging.cpp @@ -0,0 +1,57 @@ +#include "zencore/logging.h" + +#include <spdlog/sinks/stdout_color_sinks.h> + +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; +} + +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; +} + +void +InitializeLogging() +{ +} + +void +ShutdownLogging() +{ + spdlog::drop_all(); + spdlog::shutdown(); +} + +} // namespace zen::logging |