summaryrefslogtreecommitdiff
path: root/src/logger.hh
diff options
context:
space:
mode:
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..5c1e599
--- /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> syslog(std::string ident, bool verbose = false);
+
+[[nodiscard]]
+std::unique_ptr<Logger> stderr(bool verbose = false);
+
+} // namespace logger
+
+#endif // LOGGER_HH