Logger.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-20
  6. * Changed: 2022-07-03
  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. #include <ls_std/os/dynamic_goal.hpp>
  18. namespace ls::std::io
  19. {
  20. class LS_STD_DYNAMIC_GOAL Logger : public ls::std::core::Class
  21. {
  22. public:
  23. explicit Logger(const ::std::shared_ptr<ls::std::core::interface_type::IWriter> &_writer);
  24. ~Logger() override = default;
  25. void debug(const ls::std::core::type::byte *_data);
  26. void error(const ls::std::core::type::byte *_data);
  27. void fatal(const ls::std::core::type::byte *_data);
  28. ls::std::io::LogLevel getLogLevel();
  29. void info(const ls::std::core::type::byte *_data);
  30. void setLogLevel(const ls::std::io::LogLevelValue &_logLevelValue);
  31. void trace(const ls::std::core::type::byte *_data);
  32. void warn(const ls::std::core::type::byte *_data);
  33. private:
  34. ls::std::io::LogLevel logLevel{};
  35. ::std::shared_ptr<ls::std::core::interface_type::IWriter> writer{};
  36. void _assignWriter(const ::std::shared_ptr<ls::std::core::interface_type::IWriter> &_writer);
  37. static ::std::string _buildCharacterChain(size_t _amount);
  38. static ::std::string _createFillContent(const ::std::string &_text);
  39. static ::std::string _generateTimeString(tm *_localTime);
  40. void _log(const ls::std::core::type::byte *_data, const ls::std::io::LogLevel &_logLevel);
  41. static ::std::string _padRight(const ::std::string &_text);
  42. };
  43. }
  44. #endif