Logger.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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
  19. {
  20. namespace std
  21. {
  22. namespace io
  23. {
  24. class LS_STD_DYNAMIC_GOAL Logger : public ls::std::core::Class
  25. {
  26. public:
  27. explicit Logger(const ::std::shared_ptr<ls::std::core::interface_type::IWriter> &_writer);
  28. ~Logger() override = default;
  29. void debug(const ls::std::core::type::byte *_data);
  30. void error(const ls::std::core::type::byte *_data);
  31. void fatal(const ls::std::core::type::byte *_data);
  32. ls::std::io::LogLevel getLogLevel();
  33. void info(const ls::std::core::type::byte *_data);
  34. void setLogLevel(const ls::std::io::LogLevelValue &_logLevelValue);
  35. void trace(const ls::std::core::type::byte *_data);
  36. void warn(const ls::std::core::type::byte *_data);
  37. private:
  38. ls::std::io::LogLevel logLevel{};
  39. ::std::shared_ptr<ls::std::core::interface_type::IWriter> writer{};
  40. void _assignWriter(const ::std::shared_ptr<ls::std::core::interface_type::IWriter> &_writer);
  41. static ::std::string _buildCharacterChain(size_t _amount);
  42. static ::std::string _createFillContent(const ::std::string &_text);
  43. static ::std::string _generateTimeString(tm *_localTime);
  44. void _log(const ls::std::core::type::byte *_data, const ls::std::io::LogLevel &_logLevel);
  45. static ::std::string _padRight(const ::std::string& _text);
  46. };
  47. }
  48. }
  49. }
  50. #endif