summaryrefslogtreecommitdiff
path: root/src/logger.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-02-20 22:54:56 +0100
committerJoel Klinghed <the_jk@spawned.biz>2025-02-20 22:54:56 +0100
commitb4d6df902253637f24647d3db2bc3781d69eec1c (patch)
treed8bf9ac04a270fabdfee1c15628c702471ef8bf5 /src/logger.hh
parent441cafc7124f633e5abc684e85a11ce3c991f6ae (diff)
Initial commitHEADmain
Diffstat (limited to 'src/logger.hh')
-rw-r--r--src/logger.hh51
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