diff --git a/src/Log.cxx b/src/Log.cxx index eed32cd74..4d37b36f7 100644 --- a/src/Log.cxx +++ b/src/Log.cxx @@ -119,6 +119,18 @@ LogError(const std::exception &e, const char *msg) } } +void +FormatError(const std::exception &e, const char *fmt, ...) +{ + char msg[1024]; + va_list ap; + va_start(ap, fmt); + vsnprintf(msg, sizeof(msg), fmt, ap); + va_end(ap); + + LogError(e, msg); +} + void LogError(const Error &error) { diff --git a/src/Log.hxx b/src/Log.hxx index b7d55210a..1cacf5c4e 100644 --- a/src/Log.hxx +++ b/src/Log.hxx @@ -89,6 +89,10 @@ LogError(const std::exception &e); void LogError(const std::exception &e, const char *msg); +gcc_printf(2,3) +void +FormatError(const std::exception &e, const char *fmt, ...); + gcc_printf(2,3) void FormatError(const Domain &domain, const char *fmt, ...);