LogLevel.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-20
  6. * Changed: 2024-09-13
  7. *
  8. * */
  9. #ifndef LS_STD_LOG_LEVEL_HPP
  10. #define LS_STD_LOG_LEVEL_HPP
  11. #include "LogLevelValue.hpp"
  12. #include <ls-std/core/Class.hpp>
  13. #include <ls-std/os/dynamic-goal.hpp>
  14. #include <string_view>
  15. #include <unordered_map>
  16. /*
  17. * @doc: class(name: 'LogLevel', package: 'io')
  18. * @doc: io.LogLevel.description('This class represents the log level controlling how noisy a log should be.')
  19. * */
  20. namespace ls::std::io
  21. {
  22. class LS_STD_DYNAMIC_GOAL LogLevel : public ls::std::core::Class
  23. {
  24. public:
  25. explicit LogLevel(const ls::std::io::LogLevelValue &_value);
  26. LogLevel();
  27. ~LogLevel() noexcept override;
  28. ls::std::io::LogLevel &operator=(const ls::std::io::LogLevelValue &_value);
  29. bool operator<(const ls::std::io::LogLevelValue &_value) const;
  30. bool operator<=(const ls::std::io::LogLevelValue &_value) const;
  31. bool operator>(const ls::std::io::LogLevelValue &_value) const;
  32. bool operator>=(const ls::std::io::LogLevelValue &_value) const;
  33. bool operator==(const ls::std::io::LogLevelValue &_value) const;
  34. [[nodiscard]] ls::std::io::LogLevelValue getValue() const;
  35. void setLogLevel(const ls::std::io::LogLevelValue &_value);
  36. void setLogLevel(const ::std::string &_value);
  37. [[nodiscard]] ::std::string toString() const;
  38. private:
  39. ::std::unordered_map<ls::std::io::LogLevelValue, ::std::string> level{};
  40. ls::std::io::LogLevelValue value{};
  41. [[nodiscard]] ls::std::io::LogLevelValue _getValueFromString(const ::std::string &_value);
  42. void _init();
  43. [[nodiscard]] bool _isValidLogLevelString(::std::string_view _value) const;
  44. };
  45. }
  46. #endif