Log: add libfmt support

This commit is contained in:
Max Kellermann
2021-06-23 21:55:08 +02:00
parent d7df5e1c90
commit 0185d58a2b
18 changed files with 233 additions and 1 deletions

View File

@@ -21,6 +21,8 @@
#include "util/Domain.hxx"
#include "util/Exception.hxx"
#include <fmt/format.h>
#include <cerrno>
#include <stdio.h>
@@ -28,6 +30,15 @@
static constexpr Domain exception_domain("exception");
void
LogVFmt(LogLevel level, const Domain &domain,
fmt::string_view format_str, fmt::format_args args) noexcept
{
fmt::memory_buffer buffer;
fmt::vformat_to(buffer, format_str, args);
Log(level, domain, {buffer.data(), buffer.size()});
}
void
LogFormatV(LogLevel level, const Domain &domain,
const char *fmt, std::va_list ap) noexcept