Logger.hpp 1.9 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: 2023-02-23
  7. *
  8. * */
  9. #ifndef LS_STD_LOGGER_HPP
  10. #define LS_STD_LOGGER_HPP
  11. #include "LogLevel.hpp"
  12. #include <ls-std/core/Class.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 <ls-std/os/dynamic-goal.hpp>
  17. #include <string>
  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() noexcept override;
  25. void debug(const ls::std::core::type::byte_type *_data);
  26. void error(const ls::std::core::type::byte_type *_data);
  27. void fatal(const ls::std::core::type::byte_type *_data);
  28. [[nodiscard]] ls::std::io::LogLevel getLogLevel();
  29. void info(const ls::std::core::type::byte_type *_data);
  30. void setLogLevel(const ls::std::io::LogLevelValue &_logLevelValue);
  31. void trace(const ls::std::core::type::byte_type *_data);
  32. void warn(const ls::std::core::type::byte_type *_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. [[nodiscard]] static ::std::string _buildCharacterChain(size_t _amount);
  38. [[nodiscard]] static ::std::string _createFillContent(const ::std::string &_text);
  39. [[nodiscard]] static ::std::string _generateTimeString(tm *_localTime);
  40. void _log(const ls::std::core::type::byte_type *_data, const ls::std::io::LogLevel &_logLevel);
  41. [[nodiscard]] static ::std::string _padRight(const ::std::string &_text);
  42. };
  43. }
  44. #endif