Commit 72f6e018 authored by Max Kellermann's avatar Max Kellermann

Log: remove the obsolete printf-style functions

parent 2fbbd540
...@@ -25,13 +25,16 @@ ...@@ -25,13 +25,16 @@
#include "config/Data.hxx" #include "config/Data.hxx"
#include "config/Option.hxx" #include "config/Option.hxx"
#include "config/Net.hxx" #include "config/Net.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "net/AllocatedSocketAddress.hxx" #include "net/AllocatedSocketAddress.hxx"
#include "net/UniqueSocketDescriptor.hxx" #include "net/UniqueSocketDescriptor.hxx"
#include "net/SocketUtil.hxx" #include "net/SocketUtil.hxx"
#include "system/Error.hxx" #include "system/Error.hxx"
#include "util/RuntimeError.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "fs/XDG.hxx" #include "fs/XDG.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include <sys/stat.h> #include <sys/stat.h>
...@@ -41,6 +44,10 @@ ...@@ -41,6 +44,10 @@
#define DEFAULT_PORT 6600 #define DEFAULT_PORT 6600
#if defined(USE_XDG) && defined(HAVE_UN)
static constexpr Domain listen_domain("listen");
#endif
int listen_port; int listen_port;
#ifdef ENABLE_SYSTEMD_DAEMON #ifdef ENABLE_SYSTEMD_DAEMON
...@@ -98,9 +105,9 @@ ListenXdgRuntimeDir(ClientListener &listener) noexcept ...@@ -98,9 +105,9 @@ ListenXdgRuntimeDir(ClientListener &listener) noexcept
listener.AddFD(std::move(fd), std::move(address)); listener.AddFD(std::move(fd), std::move(address));
return true; return true;
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(listen_domain,
"Failed to listen on '%s' (not fatal)", "Failed to listen on '{}' (not fatal): {}",
socket_path.c_str()); socket_path, std::current_exception());
return false; return false;
} }
#else #else
......
...@@ -17,17 +17,12 @@ ...@@ -17,17 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "LogV.hxx" #include "Log.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/Exception.hxx"
#include <fmt/format.h> #include <fmt/format.h>
#include <cerrno>
#include <stdio.h>
#include <string.h>
static constexpr Domain exception_domain("exception"); static constexpr Domain exception_domain("exception");
void void
...@@ -44,127 +39,13 @@ LogVFmt(LogLevel level, const Domain &domain, ...@@ -44,127 +39,13 @@ LogVFmt(LogLevel level, const Domain &domain,
} }
void void
LogFormatV(LogLevel level, const Domain &domain,
const char *fmt, std::va_list ap) noexcept
{
char msg[1024];
vsnprintf(msg, sizeof(msg), fmt, ap);
Log(level, domain, msg);
}
void
LogFormat(LogLevel level, const Domain &domain, const char *fmt, ...) noexcept
{
std::va_list ap;
va_start(ap, fmt);
LogFormatV(level, domain, fmt, ap);
va_end(ap);
}
void
FormatDebug(const Domain &domain, const char *fmt, ...) noexcept
{
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::DEBUG, domain, fmt, ap);
va_end(ap);
}
void
FormatWarning(const Domain &domain, const char *fmt, ...) noexcept
{
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::WARNING, domain, fmt, ap);
va_end(ap);
}
void
Log(LogLevel level, const std::exception &e) noexcept
{
Log(level, exception_domain, GetFullMessage(e).c_str());
}
void
Log(LogLevel level, const std::exception &e, const char *msg) noexcept
{
LogFormat(level, exception_domain, "%s: %s", msg, GetFullMessage(e).c_str());
}
void
LogFormat(LogLevel level, const std::exception &e, const char *fmt, ...) noexcept
{
char msg[1024];
std::va_list ap;
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
Log(level, e, msg);
}
void
Log(LogLevel level, const std::exception_ptr &ep) noexcept Log(LogLevel level, const std::exception_ptr &ep) noexcept
{ {
Log(level, exception_domain, GetFullMessage(ep).c_str()); Log(level, exception_domain, GetFullMessage(ep));
} }
void void
Log(LogLevel level, const std::exception_ptr &ep, const char *msg) noexcept Log(LogLevel level, const std::exception_ptr &ep, const char *msg) noexcept
{ {
LogFormat(level, exception_domain, "%s: %s", msg, LogFmt(level, exception_domain, "{}: {}", msg, ep);
GetFullMessage(ep).c_str());
}
void
LogFormat(LogLevel level, const std::exception_ptr &ep, const char *fmt, ...) noexcept
{
char msg[1024];
std::va_list ap;
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
Log(level, ep, msg);
}
void
LogErrno(const Domain &domain, int e, const char *msg) noexcept
{
LogFormat(LogLevel::ERROR, domain, "%s: %s", msg, strerror(e));
}
void
LogErrno(const Domain &domain, const char *msg) noexcept
{
LogErrno(domain, errno, msg);
}
static void
FormatErrnoV(const Domain &domain, int e, const char *fmt, std::va_list ap) noexcept
{
char msg[1024];
vsnprintf(msg, sizeof(msg), fmt, ap);
LogErrno(domain, e, msg);
}
void
FormatErrno(const Domain &domain, int e, const char *fmt, ...) noexcept
{
std::va_list ap;
va_start(ap, fmt);
FormatErrnoV(domain, e, fmt, ap);
va_end(ap);
}
void
FormatErrno(const Domain &domain, const char *fmt, ...) noexcept
{
const int e = errno;
std::va_list ap;
va_start(ap, fmt);
FormatErrnoV(domain, e, fmt, ap);
va_end(ap);
} }
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define MPD_LOG_HXX #define MPD_LOG_HXX
#include "LogLevel.hxx" #include "LogLevel.hxx"
#include "util/Compiler.h"
#include <fmt/core.h> #include <fmt/core.h>
#if FMT_VERSION < 70000 || FMT_VERSION >= 80000 #if FMT_VERSION < 70000 || FMT_VERSION >= 80000
...@@ -97,45 +96,18 @@ FmtError(const Domain &domain, ...@@ -97,45 +96,18 @@ FmtError(const Domain &domain,
LogFmt(LogLevel::ERROR, domain, format_str, args...); LogFmt(LogLevel::ERROR, domain, format_str, args...);
} }
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 void
Log(LogLevel level, const std::exception_ptr &ep) noexcept; Log(LogLevel level, const std::exception_ptr &ep) noexcept;
void void
Log(LogLevel level, const std::exception_ptr &ep, const char *msg) noexcept; 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 static inline void
LogDebug(const Domain &domain, const char *msg) noexcept LogDebug(const Domain &domain, const char *msg) noexcept
{ {
Log(LogLevel::DEBUG, domain, msg); Log(LogLevel::DEBUG, domain, msg);
} }
gcc_printf(2,3)
void
FormatDebug(const Domain &domain, const char *fmt, ...) noexcept;
void
FormatDebug(const Domain &domain, const char *fmt, ...) noexcept;
static inline void static inline void
LogInfo(const Domain &domain, const char *msg) noexcept LogInfo(const Domain &domain, const char *msg) noexcept
{ {
...@@ -154,10 +126,6 @@ LogWarning(const Domain &domain, const char *msg) noexcept ...@@ -154,10 +126,6 @@ LogWarning(const Domain &domain, const char *msg) noexcept
Log(LogLevel::WARNING, domain, msg); Log(LogLevel::WARNING, domain, msg);
} }
gcc_printf(2,3)
void
FormatWarning(const Domain &domain, const char *fmt, ...) noexcept;
static inline void static inline void
LogError(const Domain &domain, const char *msg) noexcept LogError(const Domain &domain, const char *msg) noexcept
{ {
...@@ -165,25 +133,6 @@ LogError(const Domain &domain, const char *msg) noexcept ...@@ -165,25 +133,6 @@ LogError(const Domain &domain, const char *msg) noexcept
} }
inline void inline void
LogError(const std::exception &e) noexcept
{
Log(LogLevel::ERROR, e);
}
inline void
LogError(const std::exception &e, const char *msg) noexcept
{
Log(LogLevel::ERROR, e, msg);
}
template<typename... Args>
inline void
FormatError(const std::exception &e, const char *fmt, Args&&... args) noexcept
{
LogFormat(LogLevel::ERROR, e, fmt, std::forward<Args>(args)...);
}
inline void
LogError(const std::exception_ptr &ep) noexcept LogError(const std::exception_ptr &ep) noexcept
{ {
Log(LogLevel::ERROR, ep); Log(LogLevel::ERROR, ep);
...@@ -195,26 +144,4 @@ LogError(const std::exception_ptr &ep, const char *msg) noexcept ...@@ -195,26 +144,4 @@ LogError(const std::exception_ptr &ep, const char *msg) noexcept
Log(LogLevel::ERROR, ep, msg); Log(LogLevel::ERROR, ep, msg);
} }
template<typename... Args>
inline void
FormatError(const std::exception_ptr &ep,
const char *fmt, Args&&... args) noexcept
{
LogFormat(LogLevel::ERROR, ep, fmt, std::forward<Args>(args)...);
}
void
LogErrno(const Domain &domain, int e, const char *msg) noexcept;
void
LogErrno(const Domain &domain, const char *msg) noexcept;
gcc_printf(3,4)
void
FormatErrno(const Domain &domain, int e, const char *fmt, ...) noexcept;
gcc_printf(2,3)
void
FormatErrno(const Domain &domain, const char *fmt, ...) noexcept;
#endif /* LOG_H */ #endif /* LOG_H */
/*
* Copyright 2003-2021 The Music Player Daemon Project
* http://www.musicpd.org
*
* 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.
*
* 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.
*/
#ifndef MPD_LOGV_HXX
#define MPD_LOGV_HXX
#include "Log.hxx" // IWYU pragma: export
#include <cstdarg>
void
LogFormatV(LogLevel level, const Domain &domain,
const char *fmt, std::va_list ap) noexcept;
#endif /* LOG_H */
...@@ -19,10 +19,14 @@ ...@@ -19,10 +19,14 @@
#include "RemoteTagCache.hxx" #include "RemoteTagCache.hxx"
#include "RemoteTagCacheHandler.hxx" #include "RemoteTagCacheHandler.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "input/ScanTags.hxx" #include "input/ScanTags.hxx"
#include "util/DeleteDisposer.hxx" #include "util/DeleteDisposer.hxx"
#include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
static constexpr Domain remote_tag_cache_domain("remote_tag_cache");
RemoteTagCache::RemoteTagCache(EventLoop &event_loop, RemoteTagCache::RemoteTagCache(EventLoop &event_loop,
RemoteTagCacheHandler &_handler) noexcept RemoteTagCacheHandler &_handler) noexcept
:handler(_handler), :handler(_handler),
...@@ -60,9 +64,9 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept ...@@ -60,9 +64,9 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept
item->scanner->Start(); item->scanner->Start();
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(remote_tag_cache_domain,
"Failed to scan tags of '%s'", "Failed to scan tags of '{}': {}",
uri.c_str()); uri, std::current_exception());
item->scanner.reset(); item->scanner.reset();
...@@ -128,7 +132,8 @@ RemoteTagCache::Item::OnRemoteTag(Tag &&_tag) noexcept ...@@ -128,7 +132,8 @@ RemoteTagCache::Item::OnRemoteTag(Tag &&_tag) noexcept
void void
RemoteTagCache::Item::OnRemoteTagError(std::exception_ptr e) noexcept RemoteTagCache::Item::OnRemoteTagError(std::exception_ptr e) noexcept
{ {
FormatError(e, "Failed to scan tags of '%s'", uri.c_str()); FmtError(remote_tag_cache_domain,
"Failed to scan tags of '{}': {}", uri, e);
scanner.reset(); scanner.reset();
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "util/ScopeExit.hxx" #include "util/ScopeExit.hxx"
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx" #include "util/StringAPI.hxx"
#include "LogV.hxx" #include "Log.hxx"
extern "C" { extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
......
...@@ -21,8 +21,12 @@ ...@@ -21,8 +21,12 @@
#include "thread/Name.hxx" #include "thread/Name.hxx"
#include "thread/Slack.hxx" #include "thread/Slack.hxx"
#include "thread/Util.hxx" #include "thread/Util.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
static constexpr Domain event_domain("event");
void void
EventThread::Start() EventThread::Start()
{ {
...@@ -57,8 +61,9 @@ EventThread::Run() noexcept ...@@ -57,8 +61,9 @@ EventThread::Run() noexcept
try { try {
SetThreadRealtime(); SetThreadRealtime();
} catch (...) { } catch (...) {
Log(LogLevel::INFO, std::current_exception(), FmtInfo(event_domain,
"RTIOThread could not get realtime scheduling, continuing anyway"); "RTIOThread could not get realtime scheduling, continuing anyway: %s",
std::current_exception());
} }
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "config/Block.hxx" #include "config/Block.hxx"
#include "Log.hxx" #include "Log.hxx"
#include "PluginUnavailable.hxx" #include "PluginUnavailable.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include <cassert> #include <cassert>
...@@ -35,6 +36,8 @@ ...@@ -35,6 +36,8 @@
#include "plugins/UringInputPlugin.hxx" #include "plugins/UringInputPlugin.hxx"
#endif #endif
static constexpr Domain input_domain("input");
void void
input_stream_global_init(const ConfigData &config, EventLoop &event_loop) input_stream_global_init(const ConfigData &config, EventLoop &event_loop)
{ {
...@@ -67,14 +70,14 @@ input_stream_global_init(const ConfigData &config, EventLoop &event_loop) ...@@ -67,14 +70,14 @@ input_stream_global_init(const ConfigData &config, EventLoop &event_loop)
plugin->init(event_loop, *block); plugin->init(event_loop, *block);
input_plugins_enabled[i] = true; input_plugins_enabled[i] = true;
} catch (const PluginUnconfigured &e) { } catch (const PluginUnconfigured &e) {
LogFormat(LogLevel::DEBUG, e, FmtDebug(input_domain,
"Input plugin '%s' is not configured", "Input plugin '{}' is not configured: %s",
plugin->name); plugin->name, e.what());
continue; continue;
} catch (const PluginUnavailable &e) { } catch (const PluginUnavailable &e) {
FormatError(e, FmtDebug(input_domain,
"Input plugin '%s' is unavailable", "Input plugin '{}' is unavailable: %s",
plugin->name); plugin->name, e.what());
continue; continue;
} catch (...) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to initialize input plugin '%s'", std::throw_with_nested(FormatRuntimeError("Failed to initialize input plugin '%s'",
......
...@@ -24,8 +24,13 @@ ...@@ -24,8 +24,13 @@
#include "../InputStream.hxx" #include "../InputStream.hxx"
#include "fs/LookupFile.hxx" #include "fs/LookupFile.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
static constexpr Domain input_domain("input");
InputStreamPtr InputStreamPtr
OpenArchiveInputStream(Path path, Mutex &mutex) OpenArchiveInputStream(Path path, Mutex &mutex)
{ {
...@@ -38,8 +43,9 @@ OpenArchiveInputStream(Path path, Mutex &mutex) ...@@ -38,8 +43,9 @@ OpenArchiveInputStream(Path path, Mutex &mutex)
return nullptr; return nullptr;
} }
} catch (...) { } catch (...) {
LogFormat(LogLevel::DEBUG, std::current_exception(), FmtDebug(input_domain,
"not an archive, lookup %s failed", path.c_str()); "not an archive, lookup '{}' failed: {}",
path, std::current_exception());
return nullptr; return nullptr;
} }
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#include "LogCallback.hxx" #include "LogCallback.hxx"
#include "Domain.hxx" #include "Domain.hxx"
#include "LogV.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/StringFormat.hxx" #include "util/StringFormat.hxx"
#include "Log.hxx"
extern "C" { extern "C" {
#include <libavutil/log.h> #include <libavutil/log.h>
...@@ -60,6 +60,10 @@ FfmpegLogCallback(void *ptr, int level, const char *fmt, std::va_list vl) ...@@ -60,6 +60,10 @@ FfmpegLogCallback(void *ptr, int level, const char *fmt, std::va_list vl)
ffmpeg_domain.GetName(), ffmpeg_domain.GetName(),
cls->item_name(ptr)); cls->item_name(ptr));
const Domain d(domain); const Domain d(domain);
LogFormatV(FfmpegImportLogLevel(level), d, fmt, vl);
char msg[1024];
vsnprintf(msg, sizeof(msg), fmt, vl);
Log(FfmpegImportLogLevel(level), d, msg);
} }
} }
...@@ -18,16 +18,21 @@ ...@@ -18,16 +18,21 @@
*/ */
#include "Manager.hxx" #include "Manager.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "event/Loop.hxx" #include "event/Loop.hxx"
#include "Log.hxx"
#include "util/DeleteDisposer.hxx" #include "util/DeleteDisposer.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <string.h> #include <string.h>
static constexpr Domain nfs_domain("nfs");
void void
NfsManager::ManagedConnection::OnNfsConnectionError(std::exception_ptr &&e) noexcept NfsManager::ManagedConnection::OnNfsConnectionError(std::exception_ptr &&e) noexcept
{ {
FormatError(e, "NFS error on %s:%s", GetServer(), GetExportName()); FmtError(nfs_domain, "NFS error on '{}:{}': {}",
GetServer(), GetExportName(), e);
/* defer deletion so the caller /* defer deletion so the caller
(i.e. NfsConnection::OnSocketReady()) can still use this (i.e. NfsConnection::OnSocketReady()) can still use this
......
...@@ -21,11 +21,15 @@ ...@@ -21,11 +21,15 @@
#include "MixerControl.hxx" #include "MixerControl.hxx"
#include "MixerInternal.hxx" #include "MixerInternal.hxx"
#include "MixerList.hxx" #include "MixerList.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "pcm/Volume.hxx" #include "pcm/Volume.hxx"
#include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <cassert> #include <cassert>
static constexpr Domain mixer_domain("mixer");
gcc_pure gcc_pure
static int static int
output_mixer_get_volume(const AudioOutputControl &ao) noexcept output_mixer_get_volume(const AudioOutputControl &ao) noexcept
...@@ -40,9 +44,9 @@ output_mixer_get_volume(const AudioOutputControl &ao) noexcept ...@@ -40,9 +44,9 @@ output_mixer_get_volume(const AudioOutputControl &ao) noexcept
try { try {
return mixer_get_volume(mixer); return mixer_get_volume(mixer);
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(mixer_domain,
"Failed to read mixer for '%s'", "Failed to read mixer for '{}': {}",
ao.GetName()); ao.GetName(), std::current_exception());
return -1; return -1;
} }
} }
...@@ -83,9 +87,9 @@ output_mixer_set_volume(AudioOutputControl &ao, unsigned volume) noexcept ...@@ -83,9 +87,9 @@ output_mixer_set_volume(AudioOutputControl &ao, unsigned volume) noexcept
mixer_set_volume(mixer, volume); mixer_set_volume(mixer, volume);
return true; return true;
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(mixer_domain,
"Failed to set mixer for '%s'", "Failed to set mixer for '{}': {}",
ao.GetName()); ao.GetName(), std::current_exception());
return false; return false;
} }
} }
......
...@@ -434,8 +434,9 @@ AudioOutputControl::Task() noexcept ...@@ -434,8 +434,9 @@ AudioOutputControl::Task() noexcept
try { try {
SetThreadRealtime(); SetThreadRealtime();
} catch (...) { } catch (...) {
Log(LogLevel::INFO, std::current_exception(), FmtInfo(output_domain,
"OutputThread could not get realtime scheduling, continuing anyway"); "OutputThread could not get realtime scheduling, continuing anyway: %s",
std::current_exception());
} }
SetThreadTimerSlack(std::chrono::microseconds(100)); SetThreadTimerSlack(std::chrono::microseconds(100));
......
...@@ -194,9 +194,9 @@ FifoOutput::Cancel() noexcept ...@@ -194,9 +194,9 @@ FifoOutput::Cancel() noexcept
} while (bytes > 0 && errno != EINTR); } while (bytes > 0 && errno != EINTR);
if (bytes < 0 && errno != EAGAIN) { if (bytes < 0 && errno != EAGAIN) {
FormatErrno(fifo_output_domain, FmtError(fifo_output_domain,
"Flush of FIFO \"%s\" failed", "Flush of FIFO \"{}\" failed: %s",
path_utf8.c_str()); path_utf8, strerror(errno));
} }
} }
......
...@@ -186,9 +186,9 @@ oss_output_test_default_device() noexcept ...@@ -186,9 +186,9 @@ oss_output_test_default_device() noexcept
if (fd.Open(default_devices[i], O_WRONLY, 0)) if (fd.Open(default_devices[i], O_WRONLY, 0))
return true; return true;
FormatErrno(oss_output_domain, FmtError(oss_output_domain,
"Error opening OSS device \"%s\"", "Error opening OSS device \"{}\": {}",
default_devices[i]); default_devices[i], strerror(errno));
} }
return false; return false;
...@@ -233,8 +233,8 @@ oss_open_default( ...@@ -233,8 +233,8 @@ oss_open_default(
"{}: permission denied", dev); "{}: permission denied", dev);
break; break;
case OSS_STAT_OTHER: case OSS_STAT_OTHER:
FormatErrno(oss_output_domain, err[i], FmtError(oss_output_domain, "Error accessing {}: {}",
"Error accessing %s", dev); dev, strerror(err[i]));
} }
} }
......
...@@ -227,25 +227,23 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate) ...@@ -227,25 +227,23 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr)); FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr));
if (soxr_use_custom_recipe) if (soxr_use_custom_recipe)
FormatDebug(soxr_domain, FmtDebug(soxr_domain,
"soxr precision=%0.0f, phase_response=%0.2f, " "soxr precision={:0.0}, phase_response={:0.2}, "
"passband_end=%0.2f, stopband_begin=%0.2f scale=%0.2f", "passband_end={:0.2}, stopband_begin={:0.2} scale={:0.2}",
soxr_quality.precision, soxr_quality.phase_response, soxr_quality.precision, soxr_quality.phase_response,
soxr_quality.passband_end, soxr_quality.stopband_begin, soxr_quality.passband_end, soxr_quality.stopband_begin,
soxr_io_custom_recipe.scale); soxr_io_custom_recipe.scale);
else else
FormatDebug(soxr_domain, FmtDebug(soxr_domain,
"soxr precision=%0.0f, phase_response=%0.2f, " "soxr precision={:0.0}, phase_response={:0.2}, "
"passband_end=%0.2f, stopband_begin=%0.2f", "passband_end={:0.2}, stopband_begin={:0.2}",
soxr_quality.precision, soxr_quality.phase_response, soxr_quality.precision, soxr_quality.phase_response,
soxr_quality.passband_end, soxr_quality.stopband_begin); soxr_quality.passband_end, soxr_quality.stopband_begin);
channels = af.channels; channels = af.channels;
ratio = float(new_sample_rate) / float(af.sample_rate); ratio = float(new_sample_rate) / float(af.sample_rate);
FormatDebug(soxr_domain, FmtDebug(soxr_domain, "samplerate conversion ratio to {:.2}", ratio);
"samplerate conversion ratio to %.2lf",
double(ratio));
/* libsoxr works with floating point samples */ /* libsoxr works with floating point samples */
af.format = SampleFormat::FLOAT; af.format = SampleFormat::FLOAT;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "storage/StoragePlugin.hxx" #include "storage/StoragePlugin.hxx"
#include "storage/StorageInterface.hxx" #include "storage/StorageInterface.hxx"
#include "storage/FileInfo.hxx" #include "storage/FileInfo.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "lib/dbus/Glue.hxx" #include "lib/dbus/Glue.hxx"
#include "lib/dbus/AsyncRequest.hxx" #include "lib/dbus/AsyncRequest.hxx"
#include "lib/dbus/Message.hxx" #include "lib/dbus/Message.hxx"
...@@ -35,12 +36,15 @@ ...@@ -35,12 +36,15 @@
#include "event/Call.hxx" #include "event/Call.hxx"
#include "event/InjectEvent.hxx" #include "event/InjectEvent.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "util/Domain.hxx"
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <stdexcept>
static constexpr Domain udisks_domain("udisks");
class UdisksStorage final : public Storage { class UdisksStorage final : public Storage {
const std::string base_uri; const std::string base_uri;
const std::string id; const std::string id;
...@@ -87,9 +91,9 @@ public: ...@@ -87,9 +91,9 @@ public:
try { try {
UnmountWait(); UnmountWait();
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(udisks_domain,
"Failed to unmount '%s'", "Failed to unmount '{}': {}",
base_uri.c_str()); base_uri, std::current_exception());
} }
} }
......
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