diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-02-20 22:54:56 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-02-20 22:54:56 +0100 |
| commit | b4d6df902253637f24647d3db2bc3781d69eec1c (patch) | |
| tree | d8bf9ac04a270fabdfee1c15628c702471ef8bf5 /src/logger.hh | |
| parent | 441cafc7124f633e5abc684e85a11ce3c991f6ae (diff) | |
Diffstat (limited to 'src/logger.hh')
| -rw-r--r-- | src/logger.hh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/logger.hh b/src/logger.hh new file mode 100644 index 0000000..48d21a7 --- /dev/null +++ b/src/logger.hh @@ -0,0 +1,51 @@ +#ifndef LOGGER_HH +#define LOGGER_HH + +#include <memory> + +class Logger { +public: + virtual ~Logger() = default; + + static std::unique_ptr<Logger> create_stdio(); + static std::unique_ptr<Logger> create_null(); + + virtual void err(char const* format, ...) +#if HAVE_ATTRIBUTE_FORMAT + __attribute__((format(printf, 2, 3))) // this takes up 1 +#endif // HAVE_ATTRIBUTE_FORMAT + = 0; + + virtual void warn(char const* format, ...) +#if HAVE_ATTRIBUTE_FORMAT + __attribute__((format(printf, 2, 3))) +#endif // HAVE_ATTRIBUTE_FORMAT + = 0; + + virtual void info(char const* format, ...) +#if HAVE_ATTRIBUTE_FORMAT + __attribute__((format(printf, 2, 3))) +#endif // HAVE_ATTRIBUTE_FORMAT + = 0; + +#ifdef NDEBUG + void dbg(char const*, ...) +#if HAVE_ATTRIBUTE_FORMAT + __attribute__((format(printf, 2, 3))) +#endif // HAVE_ATTRIBUTE_FORMAT + {} +#else + virtual void dbg(char const* format, ...) +#if HAVE_ATTRIBUTE_FORMAT + __attribute__((format(printf, 2, 3))) +#endif // HAVE_ATTRIBUTE_FORMAT + = 0; +#endif + +protected: + Logger() = default; + Logger(Logger const&) = delete; + Logger& operator=(Logger const&) = delete; +}; + +#endif // LOGGER_HH |
