Logger.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-20
  6. * Changed: 2020-08-20
  7. *
  8. * */
  9. #ifndef LOGGER_HPP
  10. #define LOGGER_HPP
  11. #include "../../base/Class.hpp"
  12. #include "LogLevel.hpp"
  13. #include "../IWriter.hpp"
  14. #include "../File.hpp"
  15. #include "../FileOutputStream.hpp"
  16. #include <string>
  17. // TODO: add append functionality
  18. namespace ls_std {
  19. class Logger : public Class {
  20. public:
  21. explicit Logger(const std::string& _path);
  22. ~Logger() = default;
  23. void close();
  24. void debug(const ls_std::byte* _data);
  25. void error(const ls_std::byte* _data);
  26. void fatal(const ls_std::byte* _data);
  27. ls_std::LogLevel getLogLevel();
  28. void info(const ls_std::byte* _data);
  29. void setLogLevel(const ls_std::LogLevelValue& _logLevelValue);
  30. void trace(const ls_std::byte* _data);
  31. void warn(const ls_std::byte* _data);
  32. private:
  33. ls_std::File file;
  34. ls_std::LogLevel logLevel {};
  35. std::shared_ptr<ls_std::FileOutputStream> outputStream {};
  36. void _init();
  37. void _log(const ls_std::byte* _data, const ls_std::LogLevel& _logLevel);
  38. };
  39. }
  40. #endif