diff --git a/src/Log.cxx b/src/Log.cxx index befe238c9..3c29ef9a3 100644 --- a/src/Log.cxx +++ b/src/Log.cxx @@ -91,19 +91,19 @@ FormatError(const Domain &domain, const char *fmt, ...) noexcept } void -LogError(const std::exception &e) noexcept +Log(LogLevel level, const std::exception &e) noexcept { - LogError(exception_domain, GetFullMessage(e).c_str()); + Log(level, exception_domain, GetFullMessage(e).c_str()); } void -LogError(const std::exception &e, const char *msg) noexcept +Log(LogLevel level, const std::exception &e, const char *msg) noexcept { - FormatError(exception_domain, "%s: %s", msg, GetFullMessage(e).c_str()); + LogFormat(level, exception_domain, "%s: %s", msg, GetFullMessage(e).c_str()); } void -FormatError(const std::exception &e, const char *fmt, ...) noexcept +LogFormat(LogLevel level, const std::exception &e, const char *fmt, ...) noexcept { char msg[1024]; va_list ap; @@ -111,24 +111,24 @@ FormatError(const std::exception &e, const char *fmt, ...) noexcept vsnprintf(msg, sizeof(msg), fmt, ap); va_end(ap); - LogError(e, msg); + Log(level, e, msg); } void -LogError(const std::exception_ptr &ep) noexcept +Log(LogLevel level, const std::exception_ptr &ep) noexcept { - LogError(exception_domain, GetFullMessage(ep).c_str()); + Log(level, exception_domain, GetFullMessage(ep).c_str()); } void -LogError(const std::exception_ptr &ep, const char *msg) noexcept +Log(LogLevel level, const std::exception_ptr &ep, const char *msg) noexcept { - FormatError(exception_domain, "%s: %s", msg, - GetFullMessage(ep).c_str()); + LogFormat(level, exception_domain, "%s: %s", msg, + GetFullMessage(ep).c_str()); } void -FormatError(const std::exception_ptr &ep, const char *fmt, ...) noexcept +LogFormat(LogLevel level, const std::exception_ptr &ep, const char *fmt, ...) noexcept { char msg[1024]; va_list ap; @@ -136,7 +136,7 @@ FormatError(const std::exception_ptr &ep, const char *fmt, ...) noexcept vsnprintf(msg, sizeof(msg), fmt, ap); va_end(ap); - LogError(ep, msg); + Log(level, ep, msg); } void diff --git a/src/Log.hxx b/src/Log.hxx index 7454d96ea..f116ca439 100644 --- a/src/Log.hxx +++ b/src/Log.hxx @@ -34,6 +34,28 @@ gcc_printf(3,4) void LogFormat(LogLevel level, const Domain &domain, const char *fmt, ...) noexcept; +void +Log(LogLevel level, const std::exception &e) noexcept; + +void +Log(LogLevel level, const std::exception &e, const char *msg) noexcept; + +gcc_printf(3,4) +void +LogFormat(LogLevel level, const std::exception &e, + const char *fmt, ...) noexcept; + +void +Log(LogLevel level, const std::exception_ptr &ep) noexcept; + +void +Log(LogLevel level, const std::exception_ptr &ep, const char *msg) noexcept; + +gcc_printf(3,4) +void +LogFormat(LogLevel level, const std::exception_ptr &ep, + const char *fmt, ...) noexcept; + static inline void LogDebug(const Domain &domain, const char *msg) noexcept { @@ -80,25 +102,44 @@ LogError(const Domain &domain, const char *msg) noexcept Log(LogLevel::ERROR, domain, msg); } -void -LogError(const std::exception &e) noexcept; +inline void +LogError(const std::exception &e) noexcept +{ + Log(LogLevel::ERROR, e); +} -void -LogError(const std::exception &e, const char *msg) noexcept; +inline void +LogError(const std::exception &e, const char *msg) noexcept +{ + Log(LogLevel::ERROR, e, msg); +} -gcc_printf(2,3) -void -FormatError(const std::exception &e, const char *fmt, ...) noexcept; +template +inline void +FormatError(const std::exception &e, const char *fmt, Args&&... args) noexcept +{ + LogFormat(LogLevel::ERROR, e, fmt, std::forward(args)...); +} -void -LogError(const std::exception_ptr &ep) noexcept; +inline void +LogError(const std::exception_ptr &ep) noexcept +{ + Log(LogLevel::ERROR, ep); +} -void -LogError(const std::exception_ptr &ep, const char *msg) noexcept; +inline void +LogError(const std::exception_ptr &ep, const char *msg) noexcept +{ + Log(LogLevel::ERROR, ep, msg); +} -gcc_printf(2,3) -void -FormatError(const std::exception_ptr &ep, const char *fmt, ...) noexcept; +template +inline void +FormatError(const std::exception_ptr &ep, + const char *fmt, Args&&... args) noexcept +{ + LogFormat(LogLevel::ERROR, ep, fmt, std::forward(args)...); +} gcc_printf(2,3) void