2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2022-07-14 17:58:12 +02:00
|
|
|
* Copyright 2003-2022 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2021-10-13 16:08:48 +02:00
|
|
|
#include "Log.hxx"
|
|
|
|
#include "lib/fmt/ExceptionFormatter.hxx"
|
2016-11-10 12:58:26 +01:00
|
|
|
#include "util/Domain.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
|
2021-06-23 21:55:08 +02:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2016-11-10 12:58:26 +01:00
|
|
|
static constexpr Domain exception_domain("exception");
|
|
|
|
|
2021-06-23 21:55:08 +02:00
|
|
|
void
|
|
|
|
LogVFmt(LogLevel level, const Domain &domain,
|
|
|
|
fmt::string_view format_str, fmt::format_args args) noexcept
|
|
|
|
{
|
|
|
|
fmt::memory_buffer buffer;
|
2021-06-25 17:32:11 +02:00
|
|
|
#if FMT_VERSION >= 80000
|
|
|
|
fmt::vformat_to(std::back_inserter(buffer), format_str, args);
|
|
|
|
#else
|
2021-06-23 21:55:08 +02:00
|
|
|
fmt::vformat_to(buffer, format_str, args);
|
2021-06-25 17:32:11 +02:00
|
|
|
#endif
|
2021-06-23 21:55:08 +02:00
|
|
|
Log(level, domain, {buffer.data(), buffer.size()});
|
|
|
|
}
|
|
|
|
|
2016-09-09 19:09:40 +02:00
|
|
|
void
|
2019-05-23 12:23:28 +02:00
|
|
|
Log(LogLevel level, const std::exception_ptr &ep) noexcept
|
2016-09-09 19:09:40 +02:00
|
|
|
{
|
2021-10-13 16:08:48 +02:00
|
|
|
Log(level, exception_domain, GetFullMessage(ep));
|
2016-09-09 19:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-05-23 12:23:28 +02:00
|
|
|
Log(LogLevel level, const std::exception_ptr &ep, const char *msg) noexcept
|
2016-09-09 19:09:40 +02:00
|
|
|
{
|
2021-10-13 16:08:48 +02:00
|
|
|
LogFmt(level, exception_domain, "{}: {}", msg, ep);
|
2006-08-01 06:18:53 +02:00
|
|
|
}
|