123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #pragma once
- #ifdef WINDOWS_BUILD
- #ifdef LOGGER_EXPORTS
- #define LOGGER_API _declspec(dllexport)
- #else
- #define LOGGER_API _declspec(dllimport)
- #endif
- #elif LINUX_BUILD
- #define LOGGER_API
- #endif
- //stl
- #include <iostream>
- #include <mutex>
- #include <deque>
- //boost
- #include <asio.hpp>
- //robotics
- #include "../robot/robotics/datetime.hpp"
- #include "../robot/robotics/text_stream.hpp"
- #include "../robot/robotics/config.hpp"
- namespace robotics::v3 {
- class LOGGER_API logger_impl {
- 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<std::string> save_;
- asio::thread_pool thread_pool_;
- };
- class LOGGER_API logger_stream {
- 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_;
- };
- }
|