log_file.h 676 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "triple_buffer.h"
  3. #include <vector>
  4. #include <functional>
  5. #include <string>
  6. #include <memory>
  7. #include "easylogging++/easylogging++.h"
  8. #include <thread>
  9. #include "msg_vector.h"
  10. class LogFile
  11. {
  12. public:
  13. LogFile();
  14. ~LogFile();
  15. LogFile(const LogFile&) = delete;
  16. LogFile& operator=(const LogFile&) = delete;
  17. bool init(const char* conf_file, const char* app_name);
  18. void shut();
  19. bool trace_log(int log_type, const char* log_content);
  20. private:
  21. void check_output();
  22. private:
  23. el::Configurations conf_;
  24. TTripleBuffer<MessageVector> msg_queue_;
  25. std::thread thread_;
  26. bool running_{};
  27. size_t shrink_size_{};
  28. };