Commit 3887465d authored by Max Kellermann's avatar Max Kellermann

Log: add FormatError() overload with std::exception

parent d84f96a5
...@@ -120,6 +120,18 @@ LogError(const std::exception &e, const char *msg) ...@@ -120,6 +120,18 @@ LogError(const std::exception &e, const char *msg)
} }
void 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) LogError(const Error &error)
{ {
Log(error.GetDomain(), LogLevel::ERROR, error.GetMessage()); Log(error.GetDomain(), LogLevel::ERROR, error.GetMessage());
......
...@@ -91,6 +91,10 @@ LogError(const std::exception &e, const char *msg); ...@@ -91,6 +91,10 @@ LogError(const std::exception &e, const char *msg);
gcc_printf(2,3) gcc_printf(2,3)
void void
FormatError(const std::exception &e, const char *fmt, ...);
gcc_printf(2,3)
void
FormatError(const Domain &domain, const char *fmt, ...); FormatError(const Domain &domain, const char *fmt, ...);
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment