From 6232d13f5321b87ddf12a1aa36b4545da45f173d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 17 Nov 2021 22:34:57 +0100 Subject: Travel3: Simple image and video display site Reads the images and videos from filesystem and builds a site in memroy. --- src/logger.hh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/logger.hh (limited to 'src/logger.hh') diff --git a/src/logger.hh b/src/logger.hh new file mode 100644 index 0000000..47bbedd --- /dev/null +++ b/src/logger.hh @@ -0,0 +1,57 @@ +#ifndef LOGGER_HH +#define LOGGER_HH + +#include +#include +#include + +class Logger { +public: + virtual ~Logger() = default; + + static std::unique_ptr create_stdio(); + // Can return nullptr, will write reason to fallback. + static std::unique_ptr create_file(std::filesystem::path const& path, + Logger* fallback); + static std::unique_ptr create_syslog(std::string const& prgname); + static std::unique_ptr 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* format, ...) +#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 -- cgit v1.2.3-70-g09d2