summaryrefslogtreecommitdiff
path: root/src/logger.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-01-02 22:42:31 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-01-02 22:42:31 +0100
commit6ed8f5151719fbc14ec0ac6d28a346d1f74cf2ca (patch)
treeebe7588e89e1aa2ae5376acf85f3a3a7b2ec7e10 /src/logger.hh
Initial commitHEADmain
Diffstat (limited to 'src/logger.hh')
-rw-r--r--src/logger.hh41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/logger.hh b/src/logger.hh
new file mode 100644
index 0000000..df6879a
--- /dev/null
+++ b/src/logger.hh
@@ -0,0 +1,41 @@
+#ifndef LOGGER_HH
+#define LOGGER_HH
+
+#include <memory>
+#include <string>
+#include <string_view>
+
+namespace logger {
+
+class Logger {
+ public:
+ virtual ~Logger() = default;
+
+ virtual void err(std::string_view message) = 0;
+ virtual void warn(std::string_view message) = 0;
+ virtual void info(std::string_view message) = 0;
+
+#if defined(NDEBUG)
+ void dbg(std::string_view) {}
+#else
+ virtual void dbg(std::string_view message) = 0;
+#endif
+
+ protected:
+ Logger() = default;
+ Logger(Logger const&) = delete;
+ Logger& operator=(Logger const&) = delete;
+};
+
+[[nodiscard]]
+std::unique_ptr<Logger> noop();
+
+[[nodiscard]]
+std::unique_ptr<Logger> stderr(bool verbose = false);
+
+[[nodiscard]]
+std::unique_ptr<Logger> prefix(Logger& logger, std::string prefix);
+
+} // namespace logger
+
+#endif // LOGGER_HH