Commit 6f539cfc authored by Max Kellermann's avatar Max Kellermann

Partition, ...: use libfmt for logging

parent 0185d58a
...@@ -269,7 +269,6 @@ sources = [ ...@@ -269,7 +269,6 @@ sources = [
'src/command/CommandListBuilder.cxx', 'src/command/CommandListBuilder.cxx',
'src/Idle.cxx', 'src/Idle.cxx',
'src/IdleFlags.cxx', 'src/IdleFlags.cxx',
'src/decoder/Domain.cxx',
'src/decoder/Thread.cxx', 'src/decoder/Thread.cxx',
'src/decoder/Control.cxx', 'src/decoder/Control.cxx',
'src/decoder/Bridge.cxx', 'src/decoder/Bridge.cxx',
......
...@@ -240,16 +240,16 @@ cycle_log_files() noexcept ...@@ -240,16 +240,16 @@ cycle_log_files() noexcept
fd = open_log_file(); fd = open_log_file();
if (fd < 0) { if (fd < 0) {
const std::string out_path_utf8 = out_path.ToUTF8(); const std::string out_path_utf8 = out_path.ToUTF8();
FormatError(log_domain, FmtError(log_domain,
"error re-opening log file: %s", "error re-opening log file: {}",
out_path_utf8.c_str()); out_path_utf8);
return -1; return -1;
} }
redirect_logs(fd); redirect_logs(fd);
close(fd); close(fd);
FormatDebug(log_domain, "Done cycling log files"); LogDebug(log_domain, "Done cycling log files");
return 0; return 0;
#endif #endif
} }
...@@ -287,9 +287,8 @@ initialize_decoder_and_player(Instance &instance, ...@@ -287,9 +287,8 @@ initialize_decoder_and_player(Instance &instance,
"positive integer", s); "positive integer", s);
if (result < MIN_BUFFER_SIZE) { if (result < MIN_BUFFER_SIZE) {
FormatWarning(config_domain, "buffer size %lu is too small, using %lu bytes instead", FmtWarning(config_domain, "buffer size {} is too small, using {} bytes instead",
(unsigned long)result, result, MIN_BUFFER_SIZE);
(unsigned long)MIN_BUFFER_SIZE);
result = MIN_BUFFER_SIZE; result = MIN_BUFFER_SIZE;
} }
...@@ -521,8 +520,8 @@ MainConfigured(const struct options &options, const ConfigData &raw_config) ...@@ -521,8 +520,8 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
raw_config.GetUnsigned(ConfigOption::AUTO_UPDATE_DEPTH, raw_config.GetUnsigned(ConfigOption::AUTO_UPDATE_DEPTH,
INT_MAX)); INT_MAX));
#else #else
FormatWarning(config_domain, LogWarning(config_domain,
"inotify: auto_update was disabled. enable during compilation phase"); "inotify: auto_update was disabled. enable during compilation phase");
#endif #endif
} }
#endif #endif
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "Partition.hxx" #include "Partition.hxx"
#include "Instance.hxx" #include "Instance.hxx"
#include "Log.hxx" #include "Log.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "song/DetachedSong.hxx" #include "song/DetachedSong.hxx"
#include "mixer/Volume.hxx" #include "mixer/Volume.hxx"
#include "IdleFlags.hxx" #include "IdleFlags.hxx"
...@@ -67,13 +68,14 @@ PrefetchSong(InputCacheManager &cache, const char *uri) noexcept ...@@ -67,13 +68,14 @@ PrefetchSong(InputCacheManager &cache, const char *uri) noexcept
if (cache.Contains(uri)) if (cache.Contains(uri))
return; return;
FormatDebug(cache_domain, "Prefetch '%s'", uri); FmtDebug(cache_domain, "Prefetch '{}'", uri);
try { try {
cache.Prefetch(uri); cache.Prefetch(uri);
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(cache_domain,
"Prefetch '%s' failed", uri); "Prefetch '{}' failed: {}",
uri, std::current_exception());
} }
} }
......
...@@ -93,8 +93,8 @@ StateFile::Write(OutputStream &os) ...@@ -93,8 +93,8 @@ StateFile::Write(OutputStream &os)
void void
StateFile::Write() StateFile::Write()
{ {
FormatDebug(state_file_domain, FmtDebug(state_file_domain,
"Saving state file %s", path_utf8.c_str()); "Saving state file {}", path_utf8);
try { try {
FileOutputStream fos(config.path); FileOutputStream fos(config.path);
...@@ -112,7 +112,7 @@ StateFile::Read() ...@@ -112,7 +112,7 @@ StateFile::Read()
try { try {
bool success; bool success;
FormatDebug(state_file_domain, "Loading state file %s", path_utf8.c_str()); FmtDebug(state_file_domain, "Loading state file {}", path_utf8);
TextFile file(config.path); TextFile file(config.path);
...@@ -135,9 +135,9 @@ try { ...@@ -135,9 +135,9 @@ try {
#endif #endif
if (!success) if (!success)
FormatError(state_file_domain, FmtError(state_file_domain,
"Unrecognized line in state file: %s", "Unrecognized line in state file: {}",
line); line);
} }
RememberVersions(); RememberVersions();
......
...@@ -18,12 +18,14 @@ ...@@ -18,12 +18,14 @@
*/ */
#include "Client.hxx" #include "Client.hxx"
#include "Domain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "Log.hxx" #include "Log.hxx"
void void
Client::OnSocketError(std::exception_ptr ep) noexcept Client::OnSocketError(std::exception_ptr ep) noexcept
{ {
FormatError(ep, "error on client %d", num); FmtError(client_domain, "error on client {}: {}", num, ep);
SetExpired(); SetExpired();
} }
......
...@@ -76,8 +76,8 @@ client_new(EventLoop &loop, Partition &partition, ...@@ -76,8 +76,8 @@ client_new(EventLoop &loop, Partition &partition,
client_list.Add(*client); client_list.Add(*client);
partition.clients.push_back(*client); partition.clients.push_back(*client);
FormatInfo(client_domain, "[%u] opened from %s", FmtInfo(client_domain, "[{}] opened from {}",
num, remote.c_str()); num, remote);
} }
void void
...@@ -89,6 +89,6 @@ Client::Close() noexcept ...@@ -89,6 +89,6 @@ Client::Close() noexcept
if (FullyBufferedSocket::IsDefined()) if (FullyBufferedSocket::IsDefined())
FullyBufferedSocket::Close(); FullyBufferedSocket::Close();
FormatInfo(client_domain, "[%u] closed", num); FmtInfo(client_domain, "[{}] closed", num);
delete this; delete this;
} }
...@@ -39,9 +39,9 @@ Client::ProcessCommandList(bool list_ok, ...@@ -39,9 +39,9 @@ Client::ProcessCommandList(bool list_ok,
for (auto &&i : list) { for (auto &&i : list) {
char *cmd = &*i.begin(); char *cmd = &*i.begin();
FormatDebug(client_domain, "process command \"%s\"", cmd); FmtDebug(client_domain, "process command \"{}\"", cmd);
auto ret = command_process(*this, n++, cmd); auto ret = command_process(*this, n++, cmd);
FormatDebug(client_domain, "command returned %i", int(ret)); FmtDebug(client_domain, "command returned {}", unsigned(ret));
if (IsExpired()) if (IsExpired())
return CommandResult::CLOSE; return CommandResult::CLOSE;
else if (ret != CommandResult::OK) else if (ret != CommandResult::OK)
...@@ -62,9 +62,9 @@ Client::ProcessLine(char *line) noexcept ...@@ -62,9 +62,9 @@ Client::ProcessLine(char *line) noexcept
/* all valid MPD commands begin with a lower case /* all valid MPD commands begin with a lower case
letter; this could be a badly routed HTTP letter; this could be a badly routed HTTP
request */ request */
FormatWarning(client_domain, FmtWarning(client_domain,
"[%u] malformed command \"%s\"", "[{}] malformed command \"{}\"",
num, line); num, line);
return CommandResult::CLOSE; return CommandResult::CLOSE;
} }
...@@ -83,9 +83,9 @@ Client::ProcessLine(char *line) noexcept ...@@ -83,9 +83,9 @@ Client::ProcessLine(char *line) noexcept
} else if (idle_waiting) { } else if (idle_waiting) {
/* during idle mode, clients must not send anything /* during idle mode, clients must not send anything
except "noidle" */ except "noidle" */
FormatWarning(client_domain, FmtWarning(client_domain,
"[%u] command \"%s\" during idle", "[{}] command \"{}\" during idle",
num, line); num, line);
return CommandResult::CLOSE; return CommandResult::CLOSE;
} }
...@@ -93,9 +93,9 @@ Client::ProcessLine(char *line) noexcept ...@@ -93,9 +93,9 @@ Client::ProcessLine(char *line) noexcept
if (StringIsEqual(line, CLIENT_LIST_MODE_END)) { if (StringIsEqual(line, CLIENT_LIST_MODE_END)) {
const unsigned id = num; const unsigned id = num;
FormatDebug(client_domain, FmtDebug(client_domain,
"[%u] process command list", "[{}] process command list",
id); id);
const bool ok_mode = cmd_list.IsOKMode(); const bool ok_mode = cmd_list.IsOKMode();
auto list = cmd_list.Commit(); auto list = cmd_list.Commit();
...@@ -103,9 +103,9 @@ Client::ProcessLine(char *line) noexcept ...@@ -103,9 +103,9 @@ Client::ProcessLine(char *line) noexcept
auto ret = ProcessCommandList(ok_mode, auto ret = ProcessCommandList(ok_mode,
std::move(list)); std::move(list));
FormatDebug(client_domain, FmtDebug(client_domain,
"[%u] process command " "[{}] process command "
"list returned %i", id, int(ret)); "list returned {}", id, unsigned(ret));
if (ret == CommandResult::OK) if (ret == CommandResult::OK)
command_success(*this); command_success(*this);
...@@ -113,11 +113,10 @@ Client::ProcessLine(char *line) noexcept ...@@ -113,11 +113,10 @@ Client::ProcessLine(char *line) noexcept
return ret; return ret;
} else { } else {
if (!cmd_list.Add(line)) { if (!cmd_list.Add(line)) {
FormatWarning(client_domain, FmtWarning(client_domain,
"[%u] command list size " "[{}] command list size "
"is larger than the max (%lu)", "is larger than the max ({})",
num, num, client_max_command_list_size);
(unsigned long)client_max_command_list_size);
return CommandResult::CLOSE; return CommandResult::CLOSE;
} }
...@@ -133,13 +132,13 @@ Client::ProcessLine(char *line) noexcept ...@@ -133,13 +132,13 @@ Client::ProcessLine(char *line) noexcept
} else { } else {
const unsigned id = num; const unsigned id = num;
FormatDebug(client_domain, FmtDebug(client_domain,
"[%u] process command \"%s\"", "[{}] process command \"{}\"",
id, line); id, line);
auto ret = command_process(*this, 0, line); auto ret = command_process(*this, 0, line);
FormatDebug(client_domain, FmtDebug(client_domain,
"[%u] command returned %i", "[{}] command returned {}",
id, int(ret)); id, unsigned(ret));
if (IsExpired()) if (IsExpired())
return CommandResult::CLOSE; return CommandResult::CLOSE;
......
...@@ -33,9 +33,9 @@ Check(const ConfigBlock &block) ...@@ -33,9 +33,9 @@ Check(const ConfigBlock &block)
for (const auto &i : block.block_params) { for (const auto &i : block.block_params) {
if (!i.used) if (!i.used)
FormatWarning(config_domain, FmtWarning(config_domain,
"option '%s' on line %i was not recognized", "option '{}' on line {} was not recognized",
i.name.c_str(), i.line); i.name, i.line);
} }
} }
......
...@@ -116,9 +116,9 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader, ...@@ -116,9 +116,9 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader,
const ConfigTemplate &option = config_block_templates[i]; const ConfigTemplate &option = config_block_templates[i];
if (option.deprecated) if (option.deprecated)
FormatWarning(config_file_domain, FmtWarning(config_file_domain,
"config parameter \"%s\" on line %u is deprecated", "config parameter \"{}\" on line {} is deprecated",
name, reader.GetLineNumber()); name, reader.GetLineNumber());
if (!option.repeatable) if (!option.repeatable)
if (const auto *block = config_data.GetBlock(o)) if (const auto *block = config_data.GetBlock(o))
...@@ -148,9 +148,9 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader, ...@@ -148,9 +148,9 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
const ConfigTemplate &option = config_param_templates[i]; const ConfigTemplate &option = config_param_templates[i];
if (option.deprecated) if (option.deprecated)
FormatWarning(config_file_domain, FmtWarning(config_file_domain,
"config parameter \"%s\" on line %u is deprecated", "config parameter \"{}\" on line {} is deprecated",
name, reader.GetLineNumber()); name, reader.GetLineNumber());
if (!option.repeatable) if (!option.repeatable)
/* if the option is not repeatable, override the old /* if the option is not repeatable, override the old
...@@ -238,7 +238,7 @@ ReadConfigFile(ConfigData &config_data, Path path) ...@@ -238,7 +238,7 @@ ReadConfigFile(ConfigData &config_data, Path path)
assert(!path.IsNull()); assert(!path.IsNull());
const std::string path_utf8 = path.ToUTF8(); const std::string path_utf8 = path.ToUTF8();
FormatDebug(config_file_domain, "loading file %s", path_utf8.c_str()); FmtDebug(config_file_domain, "loading file {}", path_utf8);
FileReader file(path); FileReader file(path);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "db/plugins/simple/Directory.hxx" #include "db/plugins/simple/Directory.hxx"
#include "db/plugins/simple/Song.hxx" #include "db/plugins/simple/Song.hxx"
#include "storage/StorageInterface.hxx" #include "storage/StorageInterface.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "storage/FileInfo.hxx" #include "storage/FileInfo.hxx"
#include "archive/ArchiveList.hxx" #include "archive/ArchiveList.hxx"
...@@ -82,14 +83,14 @@ UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory, ...@@ -82,14 +83,14 @@ UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
} }
modified = true; modified = true;
FormatNotice(update_domain, "added %s/%s", FmtNotice(update_domain, "added {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
} }
} else { } else {
if (!song->UpdateFileInArchive(archive)) { if (!song->UpdateFileInArchive(archive)) {
FormatDebug(update_domain, FmtDebug(update_domain,
"deleting unrecognized file %s/%s", "deleting unrecognized file {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
editor.LockDeleteSong(directory, song); editor.LockDeleteSong(directory, song);
} }
} }
...@@ -107,8 +108,8 @@ class UpdateArchiveVisitor final : public ArchiveVisitor { ...@@ -107,8 +108,8 @@ class UpdateArchiveVisitor final : public ArchiveVisitor {
:walk(_walk), archive(_archive), directory(_directory) {} :walk(_walk), archive(_archive), directory(_directory) {}
void VisitArchiveEntry(const char *path_utf8) override { void VisitArchiveEntry(const char *path_utf8) override {
FormatDebug(update_domain, FmtDebug(update_domain,
"adding archive file: %s", path_utf8); "adding archive file: {}", path_utf8);
walk.UpdateArchiveTree(archive, directory, path_utf8); walk.UpdateArchiveTree(archive, directory, path_utf8);
} }
}; };
...@@ -149,7 +150,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, std::string_view name, ...@@ -149,7 +150,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, std::string_view name,
return; return;
} }
FormatDebug(update_domain, "archive %s opened", path_fs.c_str()); FmtDebug(update_domain, "archive {} opened", path_fs);
UpdateArchiveVisitor visitor(*this, *file, *directory); UpdateArchiveVisitor visitor(*this, *file, *directory);
file->Visit(visitor); file->Visit(visitor);
......
...@@ -75,9 +75,9 @@ UpdateWalk::UpdateContainerFile(Directory &directory, ...@@ -75,9 +75,9 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
// shouldn't be necessary but it's there.. // shouldn't be necessary but it's there..
song->mtime = info.mtime; song->mtime = info.mtime;
FormatNotice(update_domain, "added %s/%s", FmtNotice(update_domain, "added {}/{}",
contdir->GetPath(), contdir->GetPath(),
song->filename.c_str()); song->filename);
{ {
const ScopeDatabaseLock protect; const ScopeDatabaseLock protect;
......
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
#include "InotifyQueue.hxx" #include "InotifyQueue.hxx"
#include "InotifyDomain.hxx" #include "InotifyDomain.hxx"
#include "Service.hxx" #include "Service.hxx"
#include "Log.hxx" #include "UpdateDomain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "protocol/Ack.hxx" // for class ProtocolError #include "protocol/Ack.hxx" // for class ProtocolError
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
#include "Log.hxx"
/** /**
* Wait this long after the last change before calling * Wait this long after the last change before calling
...@@ -53,14 +55,15 @@ InotifyQueue::OnDelay() noexcept ...@@ -53,14 +55,15 @@ InotifyQueue::OnDelay() noexcept
throw; throw;
} }
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(update_domain,
"Failed to enqueue '%s'", uri_utf8); "Failed to enqueue '{}': {}",
uri_utf8, std::current_exception());
queue.pop_front(); queue.pop_front();
continue; continue;
} }
FormatDebug(inotify_domain, "updating '%s' job=%u", FmtDebug(inotify_domain, "updating '{}' job={}",
uri_utf8, id); uri_utf8, id);
queue.pop_front(); queue.pop_front();
} }
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "InotifyQueue.hxx" #include "InotifyQueue.hxx"
#include "InotifyDomain.hxx" #include "InotifyDomain.hxx"
#include "ExcludeList.hxx" #include "ExcludeList.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "storage/StorageInterface.hxx" #include "storage/StorageInterface.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include "input/Error.hxx" #include "input/Error.hxx"
...@@ -223,9 +225,9 @@ try { ...@@ -223,9 +225,9 @@ try {
ret = inotify_source->Add(child_path_fs.c_str(), ret = inotify_source->Add(child_path_fs.c_str(),
IN_MASK); IN_MASK);
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(inotify_domain,
"Failed to register %s", "Failed to register %s: {}",
child_path_fs.c_str()); child_path_fs, std::current_exception());
continue; continue;
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "db/DatabaseLock.hxx" #include "db/DatabaseLock.hxx"
#include "db/PlaylistVector.hxx" #include "db/PlaylistVector.hxx"
#include "db/plugins/simple/Directory.hxx" #include "db/plugins/simple/Directory.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "song/DetachedSong.hxx" #include "song/DetachedSong.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include "playlist/PlaylistPlugin.hxx" #include "playlist/PlaylistPlugin.hxx"
...@@ -49,7 +50,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name, ...@@ -49,7 +50,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
const auto uri_utf8 = storage.MapUTF8(directory->GetPath()); const auto uri_utf8 = storage.MapUTF8(directory->GetPath());
FormatDebug(update_domain, "scanning playlist '%s'", uri_utf8.c_str()); FmtDebug(update_domain, "scanning playlist '{}'", uri_utf8);
try { try {
Mutex mutex; Mutex mutex;
...@@ -80,8 +81,9 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name, ...@@ -80,8 +81,9 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
} }
} }
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(update_domain,
"Failed to scan playlist '%s'", uri_utf8.c_str()); "Failed to scan playlist '{}': {}",
uri_utf8, std::current_exception());
editor.LockDeleteDirectory(directory); editor.LockDeleteDirectory(directory);
} }
} }
......
...@@ -41,7 +41,7 @@ UpdateRemoveService::RunDeferred() noexcept ...@@ -41,7 +41,7 @@ UpdateRemoveService::RunDeferred() noexcept
} }
for (const auto &uri : copy) { for (const auto &uri : copy) {
FormatNotice(update_domain, "removing %s", uri.c_str()); FmtNotice(update_domain, "removing {}", uri);
listener.OnDatabaseSongRemoved(uri.c_str()); listener.OnDatabaseSongRemoved(uri.c_str());
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "Walk.hxx" #include "Walk.hxx"
#include "UpdateIO.hxx" #include "UpdateIO.hxx"
#include "UpdateDomain.hxx" #include "UpdateDomain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "db/DatabaseLock.hxx" #include "db/DatabaseLock.hxx"
#include "db/plugins/simple/Directory.hxx" #include "db/plugins/simple/Directory.hxx"
#include "db/plugins/simple/Song.hxx" #include "db/plugins/simple/Song.hxx"
...@@ -41,9 +42,9 @@ try { ...@@ -41,9 +42,9 @@ try {
} }
if (!directory_child_access(storage, directory, name, R_OK)) { if (!directory_child_access(storage, directory, name, R_OK)) {
FormatError(update_domain, FmtError(update_domain,
"no read permissions on %s/%s", "no read permissions on {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
if (song != nullptr) if (song != nullptr)
editor.LockDeleteSong(directory, song); editor.LockDeleteSong(directory, song);
...@@ -59,14 +60,14 @@ try { ...@@ -59,14 +60,14 @@ try {
} }
if (song == nullptr) { if (song == nullptr) {
FormatDebug(update_domain, "reading %s/%s", FmtDebug(update_domain, "reading {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
auto new_song = Song::LoadFile(storage, name, directory); auto new_song = Song::LoadFile(storage, name, directory);
if (!new_song) { if (!new_song) {
FormatDebug(update_domain, FmtDebug(update_domain,
"ignoring unrecognized file %s/%s", "ignoring unrecognized file {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
return; return;
} }
...@@ -76,24 +77,24 @@ try { ...@@ -76,24 +77,24 @@ try {
} }
modified = true; modified = true;
FormatNotice(update_domain, "added %s/%s", FmtNotice(update_domain, "added {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
} else if (info.mtime != song->mtime || walk_discard) { } else if (info.mtime != song->mtime || walk_discard) {
FormatNotice(update_domain, "updating %s/%s", FmtNotice(update_domain, "updating {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
if (!song->UpdateFile(storage)) { if (!song->UpdateFile(storage)) {
FormatDebug(update_domain, FmtDebug(update_domain,
"deleting unrecognized file %s/%s", "deleting unrecognized file {}/{}",
directory.GetPath(), name); directory.GetPath(), name);
editor.LockDeleteSong(directory, song); editor.LockDeleteSong(directory, song);
} }
modified = true; modified = true;
} }
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(update_domain,
"error reading file %s/%s", "error reading file {}/{}: {}",
directory.GetPath(), name); directory.GetPath(), name, std::current_exception());
} }
bool bool
......
...@@ -223,8 +223,8 @@ try { ...@@ -223,8 +223,8 @@ try {
if (!UpdateDirectory(*subdir, exclude_list, info)) if (!UpdateDirectory(*subdir, exclude_list, info))
editor.LockDeleteDirectory(subdir); editor.LockDeleteDirectory(subdir);
} else { } else {
FormatDebug(update_domain, FmtDebug(update_domain,
"%s is not a directory, archive or music", name); "{} is not a directory, archive or music", name);
} }
} catch (...) { } catch (...) {
LogError(std::current_exception()); LogError(std::current_exception());
...@@ -520,8 +520,8 @@ UpdateWalk::Walk(Directory &root, const char *path, bool discard) noexcept ...@@ -520,8 +520,8 @@ UpdateWalk::Walk(Directory &root, const char *path, bool discard) noexcept
return false; return false;
if (!info.IsDirectory()) { if (!info.IsDirectory()) {
FormatError(update_domain, "Not a directory: %s", FmtError(update_domain, "Not a directory: {}",
storage.MapUTF8("").c_str()); storage.MapUTF8(""));
return false; return false;
} }
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "config.h" #include "config.h"
#include "DecoderList.hxx" #include "DecoderList.hxx"
#include "DecoderPlugin.hxx" #include "DecoderPlugin.hxx"
#include "Domain.hxx"
#include "decoder/Features.h" #include "decoder/Features.h"
#include "PluginUnavailable.hxx" #include "lib/fmt/ExceptionFormatter.hxx"
#include "Log.hxx"
#include "config/Data.hxx" #include "config/Data.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include "plugins/AudiofileDecoderPlugin.hxx" #include "plugins/AudiofileDecoderPlugin.hxx"
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
#include "plugins/FluidsynthDecoderPlugin.hxx" #include "plugins/FluidsynthDecoderPlugin.hxx"
#include "plugins/SidplayDecoderPlugin.hxx" #include "plugins/SidplayDecoderPlugin.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "Log.hxx"
#include "PluginUnavailable.hxx"
#include <iterator> #include <iterator>
...@@ -160,9 +162,9 @@ decoder_plugin_init_all(const ConfigData &config) ...@@ -160,9 +162,9 @@ decoder_plugin_init_all(const ConfigData &config)
if (plugin.Init(*param)) if (plugin.Init(*param))
decoder_plugins_enabled[i] = true; decoder_plugins_enabled[i] = true;
} catch (const PluginUnavailable &e) { } catch (const PluginUnavailable &e) {
FormatError(e, FmtError(decoder_domain,
"Decoder plugin '%s' is unavailable", "Decoder plugin '{}' is unavailable: {}",
plugin.name); plugin.name, std::current_exception());
} catch (...) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to initialize decoder plugin '%s'", std::throw_with_nested(FormatRuntimeError("Failed to initialize decoder plugin '%s'",
plugin.name)); plugin.name));
......
...@@ -3,6 +3,7 @@ decoder_features = configuration_data() ...@@ -3,6 +3,7 @@ decoder_features = configuration_data()
decoder_api = static_library( decoder_api = static_library(
'decoder_api', 'decoder_api',
'DecoderAPI.cxx', 'DecoderAPI.cxx',
'Domain.cxx',
'Reader.cxx', 'Reader.cxx',
'DecoderBuffer.cxx', 'DecoderBuffer.cxx',
'DecoderPlugin.cxx', 'DecoderPlugin.cxx',
......
...@@ -357,24 +357,24 @@ faad_stream_decode(DecoderClient &client, InputStream &is, ...@@ -357,24 +357,24 @@ faad_stream_decode(DecoderClient &client, InputStream &is,
faad_decoder_decode(decoder, buffer, &frame_info); faad_decoder_decode(decoder, buffer, &frame_info);
if (frame_info.error > 0) { if (frame_info.error > 0) {
FormatWarning(faad_decoder_domain, FmtWarning(faad_decoder_domain,
"error decoding AAC stream: %s", "error decoding AAC stream: {}",
NeAACDecGetErrorMessage(frame_info.error)); NeAACDecGetErrorMessage(frame_info.error));
break; break;
} }
if (frame_info.channels != audio_format.channels) { if (frame_info.channels != audio_format.channels) {
FormatNotice(faad_decoder_domain, FmtNotice(faad_decoder_domain,
"channel count changed from %u to %u", "channel count changed from {} to {}",
audio_format.channels, frame_info.channels); audio_format.channels, frame_info.channels);
break; break;
} }
if (frame_info.samplerate != audio_format.sample_rate) { if (frame_info.samplerate != audio_format.sample_rate) {
FormatNotice(faad_decoder_domain, FmtNotice(faad_decoder_domain,
"sample rate changed from %u to %lu", "sample rate changed from {} to {}",
audio_format.sample_rate, audio_format.sample_rate,
(unsigned long)frame_info.samplerate); frame_info.samplerate);
break; break;
} }
......
...@@ -270,9 +270,9 @@ FfmpegReceiveFrames(DecoderClient &client, InputStream *is, ...@@ -270,9 +270,9 @@ FfmpegReceiveFrames(DecoderClient &client, InputStream *is,
{ {
char msg[256]; char msg[256];
av_strerror(err, msg, sizeof(msg)); av_strerror(err, msg, sizeof(msg));
FormatWarning(ffmpeg_domain, FmtWarning(ffmpeg_domain,
"avcodec_send_packet() failed: %s", "avcodec_send_packet() failed: {}",
msg); msg);
} }
return DecoderCommand::STOP; return DecoderCommand::STOP;
...@@ -326,8 +326,8 @@ ffmpeg_send_packet(DecoderClient &client, InputStream *is, ...@@ -326,8 +326,8 @@ ffmpeg_send_packet(DecoderClient &client, InputStream *is,
{ {
char msg[256]; char msg[256];
av_strerror(err, msg, sizeof(msg)); av_strerror(err, msg, sizeof(msg));
FormatWarning(ffmpeg_domain, FmtWarning(ffmpeg_domain,
"avcodec_send_packet() failed: %s", msg); "avcodec_send_packet() failed: {}", msg);
} }
return DecoderCommand::NONE; return DecoderCommand::NONE;
...@@ -355,13 +355,13 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept ...@@ -355,13 +355,13 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer), const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
sample_fmt); sample_fmt);
if (name != nullptr) if (name != nullptr)
FormatError(ffmpeg_domain, FmtError(ffmpeg_domain,
"Unsupported libavcodec SampleFormat value: %s (%d)", "Unsupported libavcodec SampleFormat value: {} ({})",
name, sample_fmt); name, sample_fmt);
else else
FormatError(ffmpeg_domain, FmtError(ffmpeg_domain,
"Unsupported libavcodec SampleFormat value: %d", "Unsupported libavcodec SampleFormat value: {}",
sample_fmt); sample_fmt);
return SampleFormat::UNDEFINED; return SampleFormat::UNDEFINED;
} }
...@@ -499,8 +499,8 @@ FfmpegDecode(DecoderClient &client, InputStream *input, ...@@ -499,8 +499,8 @@ FfmpegDecode(DecoderClient &client, InputStream *input,
const AVCodecDescriptor *codec_descriptor = const AVCodecDescriptor *codec_descriptor =
avcodec_descriptor_get(codec_params.codec_id); avcodec_descriptor_get(codec_params.codec_id);
if (codec_descriptor != nullptr) if (codec_descriptor != nullptr)
FormatDebug(ffmpeg_domain, "codec '%s'", FmtDebug(ffmpeg_domain, "codec '{}'",
codec_descriptor->name); codec_descriptor->name);
AVCodec *codec = avcodec_find_decoder(codec_params.codec_id); AVCodec *codec = avcodec_find_decoder(codec_params.codec_id);
...@@ -602,8 +602,8 @@ ffmpeg_decode(DecoderClient &client, InputStream &input) ...@@ -602,8 +602,8 @@ ffmpeg_decode(DecoderClient &client, InputStream &input)
FfmpegOpenInput(stream.io, input.GetURI(), nullptr); FfmpegOpenInput(stream.io, input.GetURI(), nullptr);
const auto *input_format = format_context->iformat; const auto *input_format = format_context->iformat;
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)", FmtDebug(ffmpeg_domain, "detected input format '{}' ({})",
input_format->name, input_format->long_name); input_format->name, input_format->long_name);
FfmpegDecode(client, &input, *format_context); FfmpegDecode(client, &input, *format_context);
} }
...@@ -668,8 +668,8 @@ ffmpeg_uri_decode(DecoderClient &client, const char *uri) ...@@ -668,8 +668,8 @@ ffmpeg_uri_decode(DecoderClient &client, const char *uri)
FfmpegOpenInput(nullptr, uri, nullptr); FfmpegOpenInput(nullptr, uri, nullptr);
const auto *input_format = format_context->iformat; const auto *input_format = format_context->iformat;
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)", FmtDebug(ffmpeg_domain, "detected input format '{}' ({})",
input_format->name, input_format->long_name); input_format->name, input_format->long_name);
FfmpegDecode(client, nullptr, *format_context); FfmpegDecode(client, nullptr, *format_context);
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include "MikmodDecoderPlugin.hxx" #include "MikmodDecoderPlugin.hxx"
#include "../DecoderAPI.hxx" #include "../DecoderAPI.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "tag/Handler.hxx" #include "tag/Handler.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
...@@ -126,9 +127,9 @@ mikmod_decoder_init(const ConfigBlock &block) ...@@ -126,9 +127,9 @@ mikmod_decoder_init(const ConfigBlock &block)
DMODE_16BITS); DMODE_16BITS);
if (MikMod_Init(params)) { if (MikMod_Init(params)) {
FormatError(mikmod_domain, FmtError(mikmod_domain,
"Could not init MikMod: %s", "Could not init MikMod: {}",
MikMod_strerror(MikMod_errno)); MikMod_strerror(MikMod_errno));
return false; return false;
} }
...@@ -155,8 +156,7 @@ mikmod_decoder_file_decode(DecoderClient &client, Path path_fs) ...@@ -155,8 +156,7 @@ mikmod_decoder_file_decode(DecoderClient &client, Path path_fs)
handle = Player_Load(path2, 128, 0); handle = Player_Load(path2, 128, 0);
if (handle == nullptr) { if (handle == nullptr) {
FormatError(mikmod_domain, FmtError(mikmod_domain, "failed to open mod: {}", path_fs);
"failed to open mod: %s", path_fs.c_str());
return; return;
} }
...@@ -189,8 +189,7 @@ mikmod_decoder_scan_file(Path path_fs, TagHandler &handler) noexcept ...@@ -189,8 +189,7 @@ mikmod_decoder_scan_file(Path path_fs, TagHandler &handler) noexcept
MODULE *handle = Player_Load(path2, 128, 0); MODULE *handle = Player_Load(path2, 128, 0);
if (handle == nullptr) { if (handle == nullptr) {
FormatDebug(mikmod_domain, FmtDebug(mikmod_domain, "Failed to open file: {}", path_fs);
"Failed to open file: %s", path_fs.c_str());
return false; return false;
} }
......
...@@ -65,9 +65,9 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs, ...@@ -65,9 +65,9 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
{ {
int error = mpg123_open(handle, path_fs); int error = mpg123_open(handle, path_fs);
if (error != MPG123_OK) { if (error != MPG123_OK) {
FormatWarning(mpg123_domain, FmtWarning(mpg123_domain,
"libmpg123 failed to open %s: %s", "libmpg123 failed to open {}: {}",
path_fs, mpg123_plain_strerror(error)); path_fs, mpg123_plain_strerror(error));
return false; return false;
} }
...@@ -77,17 +77,17 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs, ...@@ -77,17 +77,17 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
int channels, encoding; int channels, encoding;
error = mpg123_getformat(handle, &rate, &channels, &encoding); error = mpg123_getformat(handle, &rate, &channels, &encoding);
if (error != MPG123_OK) { if (error != MPG123_OK) {
FormatWarning(mpg123_domain, FmtWarning(mpg123_domain,
"mpg123_getformat() failed: %s", "mpg123_getformat() failed: {}",
mpg123_plain_strerror(error)); mpg123_plain_strerror(error));
return false; return false;
} }
if (encoding != MPG123_ENC_SIGNED_16) { if (encoding != MPG123_ENC_SIGNED_16) {
/* other formats not yet implemented */ /* other formats not yet implemented */
FormatWarning(mpg123_domain, FmtWarning(mpg123_domain,
"expected MPG123_ENC_SIGNED_16, got %d", "expected MPG123_ENC_SIGNED_16, got {}",
encoding); encoding);
return false; return false;
} }
...@@ -187,9 +187,9 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs) ...@@ -187,9 +187,9 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
int error; int error;
mpg123_handle *const handle = mpg123_new(nullptr, &error); mpg123_handle *const handle = mpg123_new(nullptr, &error);
if (handle == nullptr) { if (handle == nullptr) {
FormatError(mpg123_domain, FmtError(mpg123_domain,
"mpg123_new() failed: %s", "mpg123_new() failed: {}",
mpg123_plain_strerror(error)); mpg123_plain_strerror(error));
return; return;
} }
...@@ -238,9 +238,9 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs) ...@@ -238,9 +238,9 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
error = mpg123_read(handle, buffer, sizeof(buffer), &nbytes); error = mpg123_read(handle, buffer, sizeof(buffer), &nbytes);
if (error != MPG123_OK) { if (error != MPG123_OK) {
if (error != MPG123_DONE) if (error != MPG123_DONE)
FormatWarning(mpg123_domain, FmtWarning(mpg123_domain,
"mpg123_read() failed: %s", "mpg123_read() failed: {}",
mpg123_plain_strerror(error)); mpg123_plain_strerror(error));
break; break;
} }
...@@ -277,9 +277,9 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept ...@@ -277,9 +277,9 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept
int error; int error;
mpg123_handle *const handle = mpg123_new(nullptr, &error); mpg123_handle *const handle = mpg123_new(nullptr, &error);
if (handle == nullptr) { if (handle == nullptr) {
FormatError(mpg123_domain, FmtError(mpg123_domain,
"mpg123_new() failed: %s", "mpg123_new() failed: {}",
mpg123_plain_strerror(error)); mpg123_plain_strerror(error));
return false; return false;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "config.h" #include "config.h"
#include "ServerSocket.hxx" #include "ServerSocket.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "net/IPv4Address.hxx" #include "net/IPv4Address.hxx"
#include "net/IPv6Address.hxx" #include "net/IPv6Address.hxx"
#include "net/StaticSocketAddress.hxx" #include "net/StaticSocketAddress.hxx"
...@@ -150,16 +151,16 @@ ServerSocket::OneServerSocket::Accept() noexcept ...@@ -150,16 +151,16 @@ ServerSocket::OneServerSocket::Accept() noexcept
UniqueSocketDescriptor peer_fd(event.GetSocket().AcceptNonBlock(peer_address)); UniqueSocketDescriptor peer_fd(event.GetSocket().AcceptNonBlock(peer_address));
if (!peer_fd.IsDefined()) { if (!peer_fd.IsDefined()) {
const SocketErrorMessage msg; const SocketErrorMessage msg;
FormatError(server_socket_domain, FmtError(server_socket_domain,
"accept() failed: %s", (const char *)msg); "accept() failed: {}", (const char *)msg);
return; return;
} }
if (!peer_fd.SetKeepAlive()) { if (!peer_fd.SetKeepAlive()) {
const SocketErrorMessage msg; const SocketErrorMessage msg;
FormatError(server_socket_domain, FmtError(server_socket_domain,
"Could not set TCP keepalive option: %s", "Could not set TCP keepalive option: {}",
(const char *)msg); (const char *)msg);
} }
const auto uid = get_remote_uid(peer_fd.Get()); const auto uid = get_remote_uid(peer_fd.Get());
...@@ -227,12 +228,13 @@ ServerSocket::Open() ...@@ -227,12 +228,13 @@ ServerSocket::Open()
if (good != nullptr && good->GetSerial() == i.GetSerial()) { if (good != nullptr && good->GetSerial() == i.GetSerial()) {
const auto address_string = i.ToString(); const auto address_string = i.ToString();
const auto good_string = good->ToString(); const auto good_string = good->ToString();
FormatError(std::current_exception(), FmtError(server_socket_domain,
"bind to '%s' failed " "bind to '{}' failed "
"(continuing anyway, because " "(continuing anyway, because "
"binding to '%s' succeeded)", "binding to '{}' succeeded): {}",
address_string.c_str(), address_string,
good_string.c_str()); good_string,
std::current_exception());
} else if (bad == nullptr) { } else if (bad == nullptr) {
bad = &i; bad = &i;
......
...@@ -48,8 +48,8 @@ SetFSCharset(const char *charset) ...@@ -48,8 +48,8 @@ SetFSCharset(const char *charset)
fs_converter = IcuConverter::Create(charset); fs_converter = IcuConverter::Create(charset);
assert(fs_converter != nullptr); assert(fs_converter != nullptr);
FormatDebug(path_domain, FmtDebug(path_domain,
"SetFSCharset: fs charset is: %s", fs_charset.c_str()); "SetFSCharset: fs charset is {}", fs_charset);
} }
#endif #endif
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "CheckFile.hxx" #include "CheckFile.hxx"
#include "Log.hxx" #include "Log.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "config/Domain.hxx" #include "config/Domain.hxx"
#include "FileInfo.hxx" #include "FileInfo.hxx"
#include "Path.hxx" #include "Path.hxx"
...@@ -31,8 +32,7 @@ CheckDirectoryReadable(Path path_fs) ...@@ -31,8 +32,7 @@ CheckDirectoryReadable(Path path_fs)
try { try {
const FileInfo fi(path_fs); const FileInfo fi(path_fs);
if (!fi.IsDirectory()) { if (!fi.IsDirectory()) {
FormatError(config_domain, FmtError(config_domain, "Not a directory: {}", path_fs);
"Not a directory: %s", path_fs.ToUTF8().c_str());
return; return;
} }
...@@ -42,9 +42,9 @@ try { ...@@ -42,9 +42,9 @@ try {
const FileInfo fi2(x); const FileInfo fi2(x);
} catch (const std::system_error &e) { } catch (const std::system_error &e) {
if (IsAccessDenied(e)) if (IsAccessDenied(e))
FormatError(config_domain, FmtError(config_domain,
"No permission to traverse (\"execute\") directory: %s", "No permission to traverse (\"execute\") directory: {}",
path_fs.ToUTF8().c_str()); path_fs);
} }
#endif #endif
...@@ -52,9 +52,9 @@ try { ...@@ -52,9 +52,9 @@ try {
const DirectoryReader reader(path_fs); const DirectoryReader reader(path_fs);
} catch (const std::system_error &e) { } catch (const std::system_error &e) {
if (IsAccessDenied(e)) if (IsAccessDenied(e))
FormatError(config_domain, FmtError(config_domain,
"No permission to read directory: %s", "No permission to read directory: {}",
path_fs.ToUTF8().c_str()); path_fs);
} }
} catch (...) { } catch (...) {
LogError(std::current_exception()); LogError(std::current_exception());
......
...@@ -207,7 +207,8 @@ input_cdio_open(const char *uri, ...@@ -207,7 +207,8 @@ input_cdio_open(const char *uri,
cdio_cddap_verbose_set(drv, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT); cdio_cddap_verbose_set(drv, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
if (speed > 0) { if (speed > 0) {
FormatDebug(cdio_domain,"Attempting to set CD speed to %dx",speed); FmtDebug(cdio_domain, "Attempting to set CD speed to {}x",
speed);
cdio_cddap_speed_set(drv,speed); cdio_cddap_speed_set(drv,speed);
} }
...@@ -301,8 +302,8 @@ CdioParanoiaInputStream::Read(std::unique_lock<Mutex> &, ...@@ -301,8 +302,8 @@ CdioParanoiaInputStream::Read(std::unique_lock<Mutex> &,
} catch (...) { } catch (...) {
char *s_err = cdio_cddap_errors(drv); char *s_err = cdio_cddap_errors(drv);
if (s_err) { if (s_err) {
FormatError(cdio_domain, FmtError(cdio_domain,
"paranoia_read: %s", s_err); "paranoia_read: {}", s_err);
cdio_cddap_free_messages(s_err); cdio_cddap_free_messages(s_err);
} }
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
#include "input/ProxyInputStream.hxx" #include "input/ProxyInputStream.hxx"
#include "input/FailingInputStream.hxx" #include "input/FailingInputStream.hxx"
#include "input/InputPlugin.hxx" #include "input/InputPlugin.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/Exception.hxx"
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
#include "Log.hxx" #include "Log.hxx"
...@@ -117,8 +117,8 @@ TidalInputStream::OnTidalSession() noexcept ...@@ -117,8 +117,8 @@ TidalInputStream::OnTidalSession() noexcept
void void
TidalInputStream::OnTidalTrackSuccess(std::string url) noexcept TidalInputStream::OnTidalTrackSuccess(std::string url) noexcept
{ {
FormatDebug(tidal_domain, "Tidal track '%s' resolves to %s", FmtDebug(tidal_domain, "Tidal track '{}' resolves to {}",
track_id.c_str(), url.c_str()); track_id, url);
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
...@@ -154,8 +154,8 @@ TidalInputStream::OnTidalTrackError(std::exception_ptr e) noexcept ...@@ -154,8 +154,8 @@ TidalInputStream::OnTidalTrackError(std::exception_ptr e) noexcept
/* the session has expired - obtain a new session id /* the session has expired - obtain a new session id
by logging in again */ by logging in again */
FormatInfo(tidal_domain, "Session expired ('%s'), retrying to log in", FmtInfo(tidal_domain,
GetFullMessage(e).c_str()); "Session expired ('{}'), retrying to log in", e);
retry_login = false; retry_login = false;
tidal_session->AddLoginHandler(*this); tidal_session->AddLoginHandler(*this);
......
...@@ -38,5 +38,5 @@ LogFfmpegError(int errnum, const char *prefix) ...@@ -38,5 +38,5 @@ LogFfmpegError(int errnum, const char *prefix)
{ {
char msg[256]; char msg[256];
av_strerror(errnum, msg, sizeof(msg)); av_strerror(errnum, msg, sizeof(msg));
FormatError(ffmpeg_domain, "%s: %s", prefix, msg); FmtError(ffmpeg_domain, "{}: {}", prefix, msg);
} }
...@@ -28,5 +28,5 @@ void ...@@ -28,5 +28,5 @@ void
LogPulseError(pa_context *context, const char *prefix) noexcept LogPulseError(pa_context *context, const char *prefix) noexcept
{ {
const int e = pa_context_errno(context); const int e = pa_context_errno(context);
FormatError(pulse_domain, "%s: %s", prefix, pa_strerror(e)); FmtError(pulse_domain, "{}: {}", prefix, pa_strerror(e));
} }
...@@ -106,8 +106,8 @@ read_sw_volume_state(const char *line, MultipleOutputs &outputs) ...@@ -106,8 +106,8 @@ read_sw_volume_state(const char *line, MultipleOutputs &outputs)
if (*end == 0 && sv >= 0 && sv <= 100) if (*end == 0 && sv >= 0 && sv <= 100)
software_volume_change(outputs, sv); software_volume_change(outputs, sv);
else else
FormatWarning(volume_domain, FmtWarning(volume_domain,
"Can't parse software volume: %s", line); "Can't parse software volume: {}", line);
return true; return true;
} }
......
...@@ -125,9 +125,9 @@ AlsaMixerMonitor::DispatchSockets() noexcept ...@@ -125,9 +125,9 @@ AlsaMixerMonitor::DispatchSockets() noexcept
int err = snd_mixer_handle_events(mixer); int err = snd_mixer_handle_events(mixer);
if (err < 0) { if (err < 0) {
FormatError(alsa_mixer_domain, FmtError(alsa_mixer_domain,
"snd_mixer_handle_events() failed: %s", "snd_mixer_handle_events() failed: {}",
snd_strerror(err)); snd_strerror(err));
if (err == -ENODEV) { if (err == -ENODEV) {
/* the sound device was unplugged; disable /* the sound device was unplugged; disable
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "Control.hxx" #include "Control.hxx"
#include "Filtered.hxx" #include "Filtered.hxx"
#include "Client.hxx" #include "Client.hxx"
#include "Domain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "mixer/MixerControl.hxx" #include "mixer/MixerControl.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include "Log.hxx" #include "Log.hxx"
...@@ -286,9 +288,9 @@ AudioOutputControl::Open(std::unique_lock<Mutex> &lock, ...@@ -286,9 +288,9 @@ AudioOutputControl::Open(std::unique_lock<Mutex> &lock,
try { try {
mixer_open(output->mixer); mixer_open(output->mixer);
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to open mixer for '%s'", "Failed to open mixer for '{}': {}",
GetName()); GetName(), std::current_exception());
} }
} }
......
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
#include "Filtered.hxx" #include "Filtered.hxx"
#include "Interface.hxx" #include "Interface.hxx"
#include "Domain.hxx" #include "Domain.hxx"
#include "Log.hxx" #include "lib/fmt/AudioFormatFormatter.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "mixer/MixerInternal.hxx" #include "mixer/MixerInternal.hxx"
#include "mixer/plugins/SoftwareMixerPlugin.hxx" #include "mixer/plugins/SoftwareMixerPlugin.hxx"
#include "filter/plugins/ConvertFilterPlugin.hxx" #include "filter/plugins/ConvertFilterPlugin.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/StringBuffer.hxx" #include "util/StringBuffer.hxx"
#include "Log.hxx"
bool bool
FilteredAudioOutput::SupportsEnableDisable() const noexcept FilteredAudioOutput::SupportsEnableDisable() const noexcept
...@@ -91,10 +93,9 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) ...@@ -91,10 +93,9 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
GetLogName())); GetLogName()));
} }
FormatDebug(output_domain, FmtDebug(output_domain,
"opened %s audio_format=%s", "opened {} audio_format={}",
GetLogName(), GetLogName(), out_audio_format);
ToString(out_audio_format).c_str());
try { try {
ConfigureConvertFilter(); ConfigureConvertFilter();
...@@ -109,7 +110,7 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) ...@@ -109,7 +110,7 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
DSD and fall back to PCM */ DSD and fall back to PCM */
LogError(std::current_exception()); LogError(std::current_exception());
FormatError(output_domain, "Retrying without DSD"); LogError(output_domain, "Retrying without DSD");
desired_audio_format.format = SampleFormat::FLOAT; desired_audio_format.format = SampleFormat::FLOAT;
OpenOutputAndConvert(desired_audio_format); OpenOutputAndConvert(desired_audio_format);
...@@ -127,8 +128,9 @@ FilteredAudioOutput::CloseOutput(bool drain) noexcept ...@@ -127,8 +128,9 @@ FilteredAudioOutput::CloseOutput(bool drain) noexcept
try { try {
Drain(); Drain();
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to drain %s", GetLogName()); "Failed to drain {}: {}",
GetLogName(), std::current_exception());
} }
} else } else
Cancel(); Cancel();
...@@ -156,7 +158,7 @@ FilteredAudioOutput::Close(bool drain) noexcept ...@@ -156,7 +158,7 @@ FilteredAudioOutput::Close(bool drain) noexcept
CloseOutput(drain); CloseOutput(drain);
CloseSoftwareMixer(); CloseSoftwareMixer();
FormatDebug(output_domain, "closed %s", GetLogName()); FmtDebug(output_domain, "closed {}", GetLogName());
} }
std::chrono::steady_clock::duration std::chrono::steady_clock::duration
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "Domain.hxx" #include "Domain.hxx"
#include "OutputAPI.hxx" #include "OutputAPI.hxx"
#include "Defaults.hxx" #include "Defaults.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "pcm/AudioParser.hxx" #include "pcm/AudioParser.hxx"
#include "mixer/MixerList.hxx" #include "mixer/MixerList.hxx"
#include "mixer/MixerType.hxx" #include "mixer/MixerType.hxx"
...@@ -68,9 +69,9 @@ audio_output_detect() ...@@ -68,9 +69,9 @@ audio_output_detect()
if (plugin->test_default_device == nullptr) if (plugin->test_default_device == nullptr)
continue; continue;
FormatInfo(output_domain, FmtInfo(output_domain,
"Attempting to detect a %s audio device", "Attempting to detect a {} audio device",
plugin->name); plugin->name);
if (ao_plugin_test_default_device(plugin)) if (ao_plugin_test_default_device(plugin))
return plugin; return plugin;
} }
...@@ -188,9 +189,9 @@ FilteredAudioOutput::Configure(const ConfigBlock &block, ...@@ -188,9 +189,9 @@ FilteredAudioOutput::Configure(const ConfigBlock &block,
/* It's not really fatal - Part of the filter chain /* It's not really fatal - Part of the filter chain
has been set up already and even an empty one will has been set up already and even an empty one will
work (if only with unexpected behaviour) */ work (if only with unexpected behaviour) */
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to initialize filter chain for '%s'", "Failed to initialize filter chain for '{}': {}",
name); name, std::current_exception());
} }
} }
...@@ -238,9 +239,9 @@ FilteredAudioOutput::Setup(EventLoop &event_loop, ...@@ -238,9 +239,9 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
*prepared_filter, *prepared_filter,
mixer_listener); mixer_listener);
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to initialize hardware mixer for '%s'", "Failed to initialize hardware mixer for '{}': {}",
name); name, std::current_exception());
} }
/* use the hardware mixer for replay gain? */ /* use the hardware mixer for replay gain? */
...@@ -250,8 +251,8 @@ FilteredAudioOutput::Setup(EventLoop &event_loop, ...@@ -250,8 +251,8 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
replay_gain_filter_set_mixer(*prepared_replay_gain_filter, replay_gain_filter_set_mixer(*prepared_replay_gain_filter,
mixer, 100); mixer, 100);
else else
FormatError(output_domain, FmtError(output_domain,
"No such mixer for output '%s'", name); "No such mixer for output '{}'", name);
} else if (!StringIsEqual(replay_gain_handler, "software") && } else if (!StringIsEqual(replay_gain_handler, "software") &&
prepared_replay_gain_filter != nullptr) { prepared_replay_gain_filter != nullptr) {
throw std::runtime_error("Invalid \"replay_gain_handler\" value"); throw std::runtime_error("Invalid \"replay_gain_handler\" value");
...@@ -289,9 +290,9 @@ audio_output_new(EventLoop &normal_event_loop, EventLoop &rt_event_loop, ...@@ -289,9 +290,9 @@ audio_output_new(EventLoop &normal_event_loop, EventLoop &rt_event_loop,
plugin = audio_output_detect(); plugin = audio_output_detect();
FormatNotice(output_domain, FmtNotice(output_domain,
"Successfully detected a %s audio device", "Successfully detected a {} audio device",
plugin->name); plugin->name);
} }
/* use the real-time I/O thread only for the ALSA plugin; /* use the real-time I/O thread only for the ALSA plugin;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "Filtered.hxx" #include "Filtered.hxx"
#include "Client.hxx" #include "Client.hxx"
#include "Domain.hxx" #include "Domain.hxx"
#include "lib/fmt/AudioFormatFormatter.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "thread/Util.hxx" #include "thread/Util.hxx"
#include "thread/Slack.hxx" #include "thread/Slack.hxx"
#include "thread/Name.hxx" #include "thread/Name.hxx"
...@@ -166,10 +168,8 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format, ...@@ -166,10 +168,8 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
} }
if (f != in_audio_format || f != output->out_audio_format) if (f != in_audio_format || f != output->out_audio_format)
FormatDebug(output_domain, "converting in=%s -> f=%s -> out=%s", FmtDebug(output_domain, "converting in={} -> f={} -> out={}",
ToString(in_audio_format).c_str(), in_audio_format, f, output->out_audio_format);
ToString(f).c_str(),
ToString(output->out_audio_format).c_str());
} }
inline void inline void
...@@ -231,8 +231,9 @@ AudioOutputControl::FillSourceOrClose() noexcept ...@@ -231,8 +231,9 @@ AudioOutputControl::FillSourceOrClose() noexcept
try { try {
return source.Fill(mutex); return source.Fill(mutex);
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to filter for %s", GetLogName()); "Failed to filter for {}: {}",
GetLogName(), std::current_exception());
InternalCloseError(std::current_exception()); InternalCloseError(std::current_exception());
return false; return false;
} }
...@@ -250,9 +251,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept ...@@ -250,9 +251,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept
caught_interrupted = true; caught_interrupted = true;
return false; return false;
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to send tag to %s", "Failed to send tag to {}: {}",
GetLogName()); GetLogName(), std::current_exception());
} }
} }
...@@ -277,8 +278,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept ...@@ -277,8 +278,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept
caught_interrupted = true; caught_interrupted = true;
return false; return false;
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to play on %s", GetLogName()); "Failed to play on {}",
GetLogName(), std::current_exception());
InternalCloseError(std::current_exception()); InternalCloseError(std::current_exception());
return false; return false;
} }
...@@ -356,9 +358,9 @@ AudioOutputControl::InternalPause(std::unique_lock<Mutex> &lock) noexcept ...@@ -356,9 +358,9 @@ AudioOutputControl::InternalPause(std::unique_lock<Mutex> &lock) noexcept
success = output->IteratePause(); success = output->IteratePause();
} catch (AudioOutputInterrupted) { } catch (AudioOutputInterrupted) {
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to pause %s", "Failed to pause {}: {}",
GetLogName()); GetLogName(), std::current_exception());
} }
if (!success) { if (!success) {
...@@ -416,8 +418,9 @@ AudioOutputControl::InternalDrain() noexcept ...@@ -416,8 +418,9 @@ AudioOutputControl::InternalDrain() noexcept
output->Drain(); output->Drain();
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(output_domain,
"Failed to flush filter on %s", GetLogName()); "Failed to flush filter on {}: {}",
GetLogName(), std::current_exception());
InternalCloseError(std::current_exception()); InternalCloseError(std::current_exception());
return; return;
} }
......
...@@ -498,9 +498,9 @@ alsa_test_default_device() ...@@ -498,9 +498,9 @@ alsa_test_default_device()
int ret = snd_pcm_open(&handle, default_device, int ret = snd_pcm_open(&handle, default_device,
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if (ret) { if (ret) {
FormatError(alsa_output_domain, FmtError(alsa_output_domain,
"Error opening default ALSA device: %s", "Error opening default ALSA device: {}",
snd_strerror(-ret)); snd_strerror(-ret));
return false; return false;
} else } else
snd_pcm_close(handle); snd_pcm_close(handle);
...@@ -548,13 +548,13 @@ AlsaOutput::Setup(AudioFormat &audio_format, ...@@ -548,13 +548,13 @@ AlsaOutput::Setup(AudioFormat &audio_format,
buffer_time, period_time, buffer_time, period_time,
audio_format, params); audio_format, params);
FormatDebug(alsa_output_domain, "format=%s (%s)", FmtDebug(alsa_output_domain, "format={} ({})",
snd_pcm_format_name(hw_result.format), snd_pcm_format_name(hw_result.format),
snd_pcm_format_description(hw_result.format)); snd_pcm_format_description(hw_result.format));
FormatDebug(alsa_output_domain, "buffer_size=%u period_size=%u", FmtDebug(alsa_output_domain, "buffer_size={} period_size={}",
(unsigned)hw_result.buffer_size, hw_result.buffer_size,
(unsigned)hw_result.period_size); hw_result.period_size);
AlsaSetupSw(pcm, hw_result.buffer_size - hw_result.period_size, AlsaSetupSw(pcm, hw_result.buffer_size - hw_result.period_size,
hw_result.period_size); hw_result.period_size);
...@@ -708,9 +708,9 @@ AlsaOutput::Open(AudioFormat &audio_format) ...@@ -708,9 +708,9 @@ AlsaOutput::Open(AudioFormat &audio_format)
throw FormatRuntimeError("Failed to open ALSA device \"%s\": %s", throw FormatRuntimeError("Failed to open ALSA device \"%s\": %s",
GetDevice(), snd_strerror(err)); GetDevice(), snd_strerror(err));
FormatDebug(alsa_output_domain, "opened %s type=%s", FmtDebug(alsa_output_domain, "opened {} type={}",
snd_pcm_name(pcm), snd_pcm_name(pcm),
snd_pcm_type_name(snd_pcm_type(pcm))); snd_pcm_type_name(snd_pcm_type(pcm)));
PcmExport::Params params; PcmExport::Params params;
params.alsa_channel_order = true; params.alsa_channel_order = true;
...@@ -734,7 +734,7 @@ AlsaOutput::Open(AudioFormat &audio_format) ...@@ -734,7 +734,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
#ifdef ENABLE_DSD #ifdef ENABLE_DSD
if (params.dsd_mode == PcmExport::DsdMode::DOP) if (params.dsd_mode == PcmExport::DsdMode::DOP)
FormatDebug(alsa_output_domain, "DoP (DSD over PCM) enabled"); LogDebug(alsa_output_domain, "DoP (DSD over PCM) enabled");
#endif #endif
pcm_export->Open(audio_format.format, pcm_export->Open(audio_format.format,
...@@ -775,13 +775,13 @@ inline int ...@@ -775,13 +775,13 @@ inline int
AlsaOutput::Recover(int err) noexcept AlsaOutput::Recover(int err) noexcept
{ {
if (err == -EPIPE) { if (err == -EPIPE) {
FormatDebug(alsa_output_domain, FmtDebug(alsa_output_domain,
"Underrun on ALSA device \"%s\"", "Underrun on ALSA device \"{}\"",
GetDevice()); GetDevice());
} else if (err == -ESTRPIPE) { } else if (err == -ESTRPIPE) {
FormatDebug(alsa_output_domain, FmtDebug(alsa_output_domain,
"ALSA device \"%s\" was suspended", "ALSA device \"{}\" was suspended",
GetDevice()); GetDevice());
} }
switch (snd_pcm_state(pcm)) { switch (snd_pcm_state(pcm)) {
...@@ -1158,7 +1158,7 @@ try { ...@@ -1158,7 +1158,7 @@ try {
} }
if (throttle_silence_log.CheckUpdate(std::chrono::seconds(5))) if (throttle_silence_log.CheckUpdate(std::chrono::seconds(5)))
FormatWarning(alsa_output_domain, "Decoder is too slow; playing silence to avoid xrun"); LogWarning(alsa_output_domain, "Decoder is too slow; playing silence to avoid xrun");
/* insert some silence if the buffer has not enough /* insert some silence if the buffer has not enough
data yet, to avoid ALSA xrun */ data yet, to avoid ALSA xrun */
......
...@@ -60,8 +60,8 @@ sndio_test_default_device() ...@@ -60,8 +60,8 @@ sndio_test_default_device()
{ {
auto *hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0); auto *hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
if (!hdl) { if (!hdl) {
FormatError(sndio_output_domain, LogError(sndio_output_domain,
"Error opening default sndio device"); "Error opening default sndio device");
return false; return false;
} }
......
...@@ -391,12 +391,12 @@ SlesOutput::Cancel() noexcept ...@@ -391,12 +391,12 @@ SlesOutput::Cancel() noexcept
SLresult result = play.SetPlayState(SL_PLAYSTATE_PAUSED); SLresult result = play.SetPlayState(SL_PLAYSTATE_PAUSED);
if (result != SL_RESULT_SUCCESS) if (result != SL_RESULT_SUCCESS)
FormatError(sles_domain, "Play.SetPlayState(PAUSED) failed"); LogError(sles_domain, "Play.SetPlayState(PAUSED) failed");
result = queue.Clear(); result = queue.Clear();
if (result != SL_RESULT_SUCCESS) if (result != SL_RESULT_SUCCESS)
FormatWarning(sles_domain, LogWarning(sles_domain,
"AndroidSimpleBufferQueue.Clear() failed"); "AndroidSimpleBufferQueue.Clear() failed");
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
n_queued = 0; n_queued = 0;
......
...@@ -422,7 +422,7 @@ inline void ...@@ -422,7 +422,7 @@ inline void
WasapiOutputThread::Work() noexcept WasapiOutputThread::Work() noexcept
try { try {
SetThreadName("Wasapi Output Worker"); SetThreadName("Wasapi Output Worker");
FormatDebug(wasapi_output_domain, "Working thread started"); LogDebug(wasapi_output_domain, "Working thread started");
COM com; COM com;
AtScopeExit(this) { AtScopeExit(this) {
...@@ -448,8 +448,8 @@ try { ...@@ -448,8 +448,8 @@ try {
Status current_state = status.load(); Status current_state = status.load();
switch (current_state) { switch (current_state) {
case Status::FINISH: case Status::FINISH:
FormatDebug(wasapi_output_domain, LogDebug(wasapi_output_domain,
"Working thread stopped"); "Working thread stopped");
return; return;
case Status::PAUSE: case Status::PAUSE:
...@@ -589,8 +589,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format) ...@@ -589,8 +589,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
if (device_format.Format.wBitsPerSample == 24) { if (device_format.Format.wBitsPerSample == 24) {
params.pack24 = true; params.pack24 = true;
} }
FormatDebug(wasapi_output_domain, "Packing data: shift8=%d pack24=%d", FmtDebug(wasapi_output_domain, "Packing data: shift8={} pack24={}",
int(params.shift8), int(params.pack24)); params.shift8, params.pack24);
pcm_export.emplace(); pcm_export.emplace();
pcm_export->Open(audio_format.format, audio_format.channels, params); pcm_export->Open(audio_format.format, audio_format.channels, params);
} }
...@@ -608,11 +608,11 @@ WasapiOutput::DoOpen(AudioFormat &audio_format) ...@@ -608,11 +608,11 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
FAILED(result)) { FAILED(result)) {
throw MakeHResultError(result, "Unable to get device period"); throw MakeHResultError(result, "Unable to get device period");
} }
FormatDebug(wasapi_output_domain, FmtDebug(wasapi_output_domain,
"Default device period: %lu ns, Minimum device period: " "Default device period: {} ns, Minimum device period: "
"%lu ns", "{} ns",
(unsigned long)ns(hundred_ns(default_device_period)).count(), ns(hundred_ns(default_device_period)).count(),
(unsigned long)ns(hundred_ns(min_device_period)).count()); ns(hundred_ns(min_device_period)).count());
REFERENCE_TIME buffer_duration; REFERENCE_TIME buffer_duration;
if (Exclusive()) { if (Exclusive()) {
...@@ -621,8 +621,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format) ...@@ -621,8 +621,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
const REFERENCE_TIME align = hundred_ns(ms(50)).count(); const REFERENCE_TIME align = hundred_ns(ms(50)).count();
buffer_duration = (align / default_device_period) * default_device_period; buffer_duration = (align / default_device_period) * default_device_period;
} }
FormatDebug(wasapi_output_domain, "Buffer duration: %lu ns", FmtDebug(wasapi_output_domain, "Buffer duration: {} ns",
(unsigned long)ns(hundred_ns(buffer_duration)).count()); ns(hundred_ns(buffer_duration)).count());
if (Exclusive()) { if (Exclusive()) {
if (HRESULT result = client->Initialize( if (HRESULT result = client->Initialize(
...@@ -639,10 +639,9 @@ WasapiOutput::DoOpen(AudioFormat &audio_format) ...@@ -639,10 +639,9 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
std::ceil(double(buffer_size_in_frames * std::ceil(double(buffer_size_in_frames *
hundred_ns(s(1)).count()) / hundred_ns(s(1)).count()) /
SampleRate()); SampleRate());
FormatDebug( FmtDebug(wasapi_output_domain,
wasapi_output_domain, "Aligned buffer duration: {} ns",
"Aligned buffer duration: %lu ns", ns(hundred_ns(buffer_duration)).count());
(unsigned long)ns(hundred_ns(buffer_duration)).count());
client.reset(); client.reset();
client = Activate<IAudioClient>(*device); client = Activate<IAudioClient>(*device);
result = client->Initialize( result = client->Initialize(
...@@ -687,8 +686,7 @@ WasapiOutput::Close() noexcept ...@@ -687,8 +686,7 @@ WasapiOutput::Close() noexcept
try { try {
thread->CheckException(); thread->CheckException();
} catch (...) { } catch (...) {
FormatError(std::current_exception(), LogError(wasapi_output_domain, "exception while stopping");
"exception while stopping");
} }
thread->Finish(); thread->Finish();
com_worker->Async([&]() { com_worker->Async([&]() {
...@@ -1029,8 +1027,8 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator) ...@@ -1029,8 +1027,8 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator)
if (name == nullptr) if (name == nullptr)
continue; continue;
FormatNotice(wasapi_output_domain, FmtNotice(wasapi_output_domain,
"Device \"%u\" \"%s\"", i, name.c_str()); "Device \"{}\" \"{}\"", i, name);
} }
} }
......
...@@ -558,10 +558,10 @@ Player::CheckDecoderStartup(std::unique_lock<Mutex> &lock) noexcept ...@@ -558,10 +558,10 @@ Player::CheckDecoderStartup(std::unique_lock<Mutex> &lock) noexcept
} }
if (!paused && !OpenOutput()) { if (!paused && !OpenOutput()) {
FormatError(player_domain, FmtError(player_domain,
"problems opening audio device " "problems opening audio device "
"while playing \"%s\"", "while playing \"{}\"",
dc.song->GetURI()); dc.song->GetURI());
return true; return true;
} }
...@@ -964,7 +964,7 @@ Player::SongBorder() noexcept ...@@ -964,7 +964,7 @@ Player::SongBorder() noexcept
{ {
const ScopeUnlock unlock(pc.mutex); const ScopeUnlock unlock(pc.mutex);
FormatNotice(player_domain, "played \"%s\"", song->GetURI()); FmtNotice(player_domain, "played \"{}\"", song->GetURI());
ReplacePipe(dc.pipe); ReplacePipe(dc.pipe);
...@@ -1135,7 +1135,7 @@ Player::Run() noexcept ...@@ -1135,7 +1135,7 @@ Player::Run() noexcept
cross_fade_tag.reset(); cross_fade_tag.reset();
if (song != nullptr) { if (song != nullptr) {
FormatNotice(player_domain, "played \"%s\"", song->GetURI()); FmtNotice(player_domain, "played \"{}\"", song->GetURI());
song.reset(); song.reset();
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
#include "StorageState.hxx" #include "StorageState.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "fs/io/TextFile.hxx" #include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx" #include "fs/io/BufferedOutputStream.hxx"
#include "storage/Registry.hxx" #include "storage/Registry.hxx"
...@@ -90,7 +91,9 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) ...@@ -90,7 +91,9 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
else if ((value = StringAfterPrefix(line, MOUNT_STATE_STORAGE_URI))) else if ((value = StringAfterPrefix(line, MOUNT_STATE_STORAGE_URI)))
uri = value; uri = value;
else else
FormatError(storage_domain, "Unrecognized line in mountpoint state: %s", line); FmtError(storage_domain,
"Unrecognized line in mountpoint state: {}",
line);
} }
if (instance.storage == nullptr) if (instance.storage == nullptr)
...@@ -104,7 +107,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) ...@@ -104,7 +107,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
return true; return true;
} }
FormatDebug(storage_domain, "Restoring mount %s => %s", uri.c_str(), url.c_str()); FmtDebug(storage_domain, "Restoring mount {} => {}", uri, url);
auto &composite_storage = *(CompositeStorage *)instance.storage; auto &composite_storage = *(CompositeStorage *)instance.storage;
if (composite_storage.IsMountPoint(uri.c_str())) { if (composite_storage.IsMountPoint(uri.c_str())) {
...@@ -120,7 +123,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) ...@@ -120,7 +123,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
auto &event_loop = instance.io_thread.GetEventLoop(); auto &event_loop = instance.io_thread.GetEventLoop();
auto storage = CreateStorageURI(event_loop, url.c_str()); auto storage = CreateStorageURI(event_loop, url.c_str());
if (storage == nullptr) { if (storage == nullptr) {
FormatError(storage_domain, "Unrecognized storage URI: %s", url.c_str()); FmtError(storage_domain, "Unrecognized storage URI: {}", url);
return true; return true;
} }
...@@ -128,9 +131,9 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) ...@@ -128,9 +131,9 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
try { try {
db->Mount(uri.c_str(), url.c_str()); db->Mount(uri.c_str(), url.c_str());
} catch (...) { } catch (...) {
FormatError(std::current_exception(), FmtError(storage_domain,
"Failed to restore mount to %s", "Failed to restore mount to {}: {}",
url.c_str()); url, std::current_exception());
return true; return true;
} }
} }
......
...@@ -83,7 +83,7 @@ FatalSystemError(const char *msg) ...@@ -83,7 +83,7 @@ FatalSystemError(const char *msg)
FatalSystemError(msg, GetLastError()); FatalSystemError(msg, GetLastError());
#else #else
auto system_error = std::strerror(errno); auto system_error = std::strerror(errno);
FormatError(fatal_error_domain, "%s: %s", msg, system_error); FmtError(fatal_error_domain, "{}: {}", msg, system_error);
Abort(); Abort();
#endif #endif
} }
......
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