From b89257a34b2a98b737f4ae544f7e436b9000b240 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 9 Jun 2018 16:03:14 +0300 Subject: Migrate to mtxclient for the http calls --- src/Logging.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/Logging.cpp (limited to 'src/Logging.cpp') diff --git a/src/Logging.cpp b/src/Logging.cpp new file mode 100644 index 00000000..c6c1c502 --- /dev/null +++ b/src/Logging.cpp @@ -0,0 +1,50 @@ +#include "Logging.hpp" + +#include +#include + +namespace { +std::shared_ptr db_logger = nullptr; +std::shared_ptr net_logger = nullptr; +std::shared_ptr main_logger = nullptr; + +constexpr auto MAX_FILE_SIZE = 1024 * 1024 * 6; +constexpr auto MAX_LOG_FILES = 3; +} + +namespace log { +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)); + main_logger = std::make_shared("main", std::begin(sinks), std::end(sinks)); + db_logger = std::make_shared("db", std::begin(sinks), std::end(sinks)); +} + +std::shared_ptr +main() +{ + return main_logger; +} + +std::shared_ptr +net() +{ + return net_logger; +} + +std::shared_ptr +db() +{ + return db_logger; +} +} -- cgit 1.5.1