logger.h 774 B

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