| 1 | #ifndef LOGGER_HPP_ |
| 2 | #define LOGGER_HPP_ |
| 3 |
|
| 4 |
|
| 5 | #include <ostream> |
| 6 | #include <string> |
| 7 | #include <fmt/format.h> |
| 8 |
|
| 9 |
|
| 10 | class Logger |
| 11 | { |
| 12 | public: |
| 13 | Logger(std::string logger_name); |
| 14 | ~Logger() = default; |
| 15 |
|
| 16 | enum Verbosity |
| 17 | { |
| 18 | DISABLED, |
| 19 | ERROR, |
| 20 | WARNING, |
| 21 | INFO, |
| 22 | DEBUG, |
| 23 | VERBOSE, |
| 24 | TRACE, |
| 25 | }; |
| 26 |
|
| 27 | static void InitializeLogging(Verbosity max_verbosity, std::ostream *ostream); |
| 28 |
|
| 29 | void Log(Verbosity verbosity, std::string message); |
| 30 |
|
| 31 | template<typename... Args> |
| 32 | void Log(Verbosity verbosity, fmt::format_string<Args...> message, Args&&... args) |
| 33 | { |
| 34 | Log(verbosity, fmt::vformat(message, fmt::make_format_args(args...))); |
| 35 | } |
| 36 |
|
| 37 | protected: |
| 38 | static std::ostream *s_ostream; |
| 39 | static Verbosity s_maxVerbosity; |
| 40 |
|
| 41 | std::string m_loggerName; |
| 42 | }; |
| 43 |
|
| 44 |
|
| 45 | #endif /* LOGGER_HPP_ */ |
| 46 |
|