Logger.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-20
  6. * Changed: 2022-05-19
  7. *
  8. * */
  9. #ifndef LS_STD_LOGGER_HPP
  10. #define LS_STD_LOGGER_HPP
  11. #include <ls_std/core/Class.hpp>
  12. #include "LogLevel.hpp"
  13. #include <ls_std/core/interface/IWriter.hpp>
  14. #include <ls_std/io/File.hpp>
  15. #include <ls_std/io/FileOutputStream.hpp>
  16. #include <string>
  17. namespace ls
  18. {
  19. namespace std
  20. {
  21. namespace io
  22. {
  23. class Logger : public ls::std::core::Class
  24. {
  25. public:
  26. explicit Logger(const ::std::shared_ptr<ls::std::core::interface_type::IWriter> &_writer);
  27. ~Logger() override = default;
  28. void debug(const ls::std::core::type::byte *_data);
  29. void error(const ls::std::core::type::byte *_data);
  30. void fatal(const ls::std::core::type::byte *_data);
  31. ls::std::io::LogLevel getLogLevel();
  32. void info(const ls::std::core::type::byte *_data);
  33. void setLogLevel(const ls::std::io::LogLevelValue &_logLevelValue);
  34. void trace(const ls::std::core::type::byte *_data);
  35. void warn(const ls::std::core::type::byte *_data);
  36. private:
  37. ls::std::io::LogLevel logLevel{};
  38. ::std::shared_ptr<ls::std::core::interface_type::IWriter> writer{};
  39. void _assignWriter(const ::std::shared_ptr<ls::std::core::interface_type::IWriter> &_writer);
  40. static ::std::string _buildCharacterChain(size_t _amount);
  41. static ::std::string _createFillContent(const ::std::string &_text);
  42. static ::std::string _generateTimeString(tm *_localTime);
  43. void _log(const ls::std::core::type::byte *_data, const ls::std::io::LogLevel &_logLevel);
  44. static ::std::string _padRight(const ::std::string& _text);
  45. };
  46. }
  47. }
  48. }
  49. #endif