#include "Logging.h" #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/stdout_color_sinks.h" #include namespace { std::shared_ptr db_logger = nullptr; std::shared_ptr net_logger = nullptr; std::shared_ptr crypto_logger = nullptr; std::shared_ptr ui_logger = nullptr; constexpr auto MAX_FILE_SIZE = 1024 * 1024 * 6; constexpr auto MAX_LOG_FILES = 3; } namespace nhlog { void init(const std::string &file_path) { auto file_sink = std::make_shared( file_path, MAX_FILE_SIZE, MAX_LOG_FILES); auto console_sink = std::make_shared(); std::vector sinks; sinks.push_back(file_sink); sinks.push_back(console_sink); net_logger = std::make_shared("net", std::begin(sinks), std::end(sinks)); ui_logger = std::make_shared("ui", std::begin(sinks), std::end(sinks)); db_logger = std::make_shared("db", std::begin(sinks), std::end(sinks)); crypto_logger = std::make_shared("crypto", std::begin(sinks), std::end(sinks)); } std::shared_ptr ui() { return ui_logger; } std::shared_ptr net() { return net_logger; } std::shared_ptr db() { return db_logger; } std::shared_ptr crypto() { return crypto_logger; } }