#pragma once #ifdef WINDOWS_BUILD #ifdef LOGGERIMPL_EXPORTS #define LOGGER_IMPL _declspec(dllexport) #else #define LOGGER_IMPL _declspec(dllimport) #endif #endif //stl #include #include #include //boost #include //robotics #include "../robot/robotics/datetime.hpp" #include "../robot/robotics/text_stream.hpp" #include "../robot/robotics/config.hpp" namespace robotics::v3 { #ifdef WINDOWS_BUILD class LOGGER_IMPL logger_impl { #elif LINUX_BUILD class logger_impl { #endif public: ~logger_impl(); void write(int color, std::string const& type, std::string const& time, std::string const& file, std::string const& func, int line, std::thread::id thread_id, std::string const& text); static logger_impl& instance(); static void install(std::string const& filename = "./config/config.ini"); private: explicit logger_impl(); void backup(std::string const& filename); void remove(); private: int max_time_ = 30; int max_size_ = 10; std::set save_; asio::thread_pool thread_pool_; }; #ifdef WINDOWS_BUILD class LOGGER_IMPL logger_stream { #elif LINUX_BUILD class logger_stream { #endif public: explicit logger_stream(int color, std::string const& type, std::string const& time, std::string const& file, std::string const& func, int line, std::thread::id thread_id); ~logger_stream(); text_stream stream; private: std::string type_; std::string time_; std::string file_; std::string func_; int line_ = 0; int color_ = 37; std::thread::id thread_id_; }; }