log_sys.h 1022 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # ifndef LOG_SYS_H
  2. # define LOG_SYS_H
  3. # include <iostream>
  4. # include <fstream>
  5. # include <string>
  6. # include <time.h>
  7. # include <stdio.h>
  8. # include <stdlib.h>
  9. //# include "utilities.h"
  10. using std::cout;
  11. using std::string;
  12. using std::endl;
  13. using std::to_string;
  14. using std::ios;
  15. class Logger{
  16. public:
  17. enum log_level{debug, info, warning, error};// 日志等级
  18. enum log_target{file, terminal, file_and_terminal};// 日志输出目标
  19. private:
  20. std::ofstream outfile; // 将日志输出到文件的流对象
  21. log_target target; // 日志输出目标
  22. string path; // 日志文件路径
  23. log_level level; // 日志等级
  24. void output(string text, log_level act_level); // 输出行为
  25. public:
  26. Logger(); // 默认构造函数
  27. Logger(log_target target, log_level level, string path);
  28. void DEBUG(string text);
  29. void INFO(string text);
  30. void WARNING(string text);
  31. //void ERROR(string text);
  32. };
  33. # endif