logger.h 830 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <mutex>
  6. using namespace std;
  7. namespace graft_cv{
  8. class CGcvLogger{
  9. public:
  10. enum log_level{debug,info, warning,error};
  11. enum log_target{file,terminal,file_and_terminal};
  12. private:
  13. ofstream& m_outfile;
  14. log_target m_target;
  15. string m_path;
  16. log_level m_level;
  17. std::shared_ptr<std::mutex> m_pMtx;
  18. void output(string text, log_level act_level);
  19. public:
  20. CGcvLogger(ofstream&);
  21. CGcvLogger(ofstream&,
  22. log_target target,
  23. log_level level,
  24. string path);
  25. void setPath(const string& path);
  26. string & getPath();
  27. void setLevel(log_level lev){
  28. m_level = lev;
  29. };
  30. int getLevel(){return m_level;};
  31. void DEBUG(string text);
  32. void INFO(string text);
  33. void WARNING(string text);
  34. void ERRORINFO(string text);
  35. };
  36. };