From 0c1ecc96a8a5e255cb64da3e2be92b589699458f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 16 Apr 2024 11:06:34 +0200 Subject: [PATCH] *: let libfmt quote strings --- src/Listen.cxx | 2 +- src/LogInit.cxx | 6 +++--- src/Partition.cxx | 4 ++-- src/Permission.cxx | 4 ++-- src/RemoteTagCache.cxx | 4 ++-- src/archive/plugins/ZzipArchivePlugin.cxx | 8 ++++---- src/client/Process.cxx | 8 ++++---- src/command/AllCommands.cxx | 10 +++++----- src/command/DatabaseCommands.cxx | 2 +- src/command/StickerCommands.cxx | 20 +++++++++---------- src/config/Block.cxx | 2 +- src/config/Check.cxx | 2 +- src/config/Data.cxx | 2 +- src/config/File.cxx | 8 ++++---- src/config/Parser.cxx | 2 +- src/config/PlayerConfig.cxx | 4 ++-- src/db/DatabaseGlue.cxx | 4 ++-- src/db/plugins/ProxyDatabasePlugin.cxx | 2 +- src/db/plugins/simple/DatabaseSave.cxx | 6 +++--- src/db/plugins/simple/DirectorySave.cxx | 8 ++++---- .../plugins/simple/SimpleDatabasePlugin.cxx | 4 ++-- src/db/update/InotifyQueue.cxx | 4 ++-- src/db/update/Playlist.cxx | 4 ++-- src/decoder/DecoderList.cxx | 4 ++-- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 10 +++++----- src/decoder/plugins/GmeDecoderPlugin.cxx | 2 +- src/decoder/plugins/MadDecoderPlugin.cxx | 2 +- src/decoder/plugins/SidplayDecoderPlugin.cxx | 4 ++-- src/decoder/plugins/WavpackDecoderPlugin.cxx | 2 +- src/encoder/plugins/LameEncoderPlugin.cxx | 2 +- src/encoder/plugins/TwolameEncoderPlugin.cxx | 2 +- src/encoder/plugins/VorbisEncoderPlugin.cxx | 2 +- src/filter/plugins/TwoFilters.cxx | 2 +- src/input/Init.cxx | 6 +++--- src/input/plugins/AlsaInputPlugin.cxx | 4 ++-- src/input/plugins/ArchiveInputPlugin.cxx | 2 +- src/lib/ffmpeg/Filter.cxx | 2 +- src/lib/icu/Converter.cxx | 4 ++-- src/lib/sqlite/Database.cxx | 2 +- src/mixer/All.cxx | 6 +++--- src/mixer/plugins/OssMixerPlugin.cxx | 6 +++--- src/mixer/plugins/PulseMixerPlugin.cxx | 2 +- src/neighbor/Glue.cxx | 4 ++-- .../plugins/SmbclientNeighborPlugin.cxx | 2 +- src/output/Control.cxx | 2 +- src/output/Init.cxx | 10 +++++----- src/output/State.cxx | 2 +- src/output/plugins/AlsaOutputPlugin.cxx | 10 +++++----- src/output/plugins/AoOutputPlugin.cxx | 6 +++--- src/output/plugins/FifoOutputPlugin.cxx | 14 ++++++------- src/output/plugins/JackOutputPlugin.cxx | 4 ++-- src/output/plugins/OSXOutputPlugin.cxx | 4 ++-- src/output/plugins/OpenALOutputPlugin.cxx | 4 ++-- src/output/plugins/OssOutputPlugin.cxx | 8 ++++---- src/output/plugins/PipeOutputPlugin.cxx | 2 +- src/output/plugins/RecorderOutputPlugin.cxx | 2 +- src/output/plugins/ShoutOutputPlugin.cxx | 8 ++++---- src/output/plugins/WinmmOutputPlugin.cxx | 4 ++-- .../plugins/wasapi/WasapiOutputPlugin.cxx | 4 ++-- src/pcm/LibsamplerateResampler.cxx | 4 ++-- src/pcm/SoxrResampler.cxx | 6 +++--- src/player/Thread.cxx | 6 +++--- src/playlist/PlaylistQueue.cxx | 2 +- src/queue/Playlist.cxx | 4 ++-- src/storage/plugins/UdisksStorage.cxx | 2 +- src/tag/Config.cxx | 2 +- src/unix/Daemon.cxx | 10 +++++----- src/unix/PidFile.hxx | 2 +- src/zeroconf/Bonjour.cxx | 2 +- src/zeroconf/avahi/Helper.cxx | 2 +- test/DumpDatabase.cxx | 2 +- 71 files changed, 160 insertions(+), 160 deletions(-) diff --git a/src/Listen.cxx b/src/Listen.cxx index 1bb8e8a7b..296aa67e4 100644 --- a/src/Listen.cxx +++ b/src/Listen.cxx @@ -88,7 +88,7 @@ ListenXdgRuntimeDir(ClientListener &listener) noexcept return true; } catch (...) { FmtError(listen_domain, - "Failed to listen on '{}' (not fatal): {}", + "Failed to listen on {:?} (not fatal): {}", socket_path, std::current_exception()); return false; } diff --git a/src/LogInit.cxx b/src/LogInit.cxx index e00ad9798..3203e6e00 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -63,10 +63,10 @@ log_init_file(int line) out_fd = open_log_file(); if (out_fd < 0) { #ifdef _WIN32 - throw FmtRuntimeError("failed to open log file \"{}\" (config line {})", + throw FmtRuntimeError("failed to open log file {:?} (config line {})", out_path, line); #else - throw FmtErrno("failed to open log file \"{}\" (config line {})", + throw FmtErrno("failed to open log file {:?} (config line {})", out_path, line); #endif } @@ -92,7 +92,7 @@ parse_log_level(const char *value) else if (StringIsEqual(value, "error")) return LogLevel::ERROR; else - throw FmtRuntimeError("unknown log level \"{}\"", value); + throw FmtRuntimeError("unknown log level {:?}", value); } #endif diff --git a/src/Partition.cxx b/src/Partition.cxx index 7020e305d..f37dfa6b6 100644 --- a/src/Partition.cxx +++ b/src/Partition.cxx @@ -49,13 +49,13 @@ PrefetchSong(InputCacheManager &cache, const char *uri) noexcept if (cache.Contains(uri)) return; - FmtDebug(cache_domain, "Prefetch '{}'", uri); + FmtDebug(cache_domain, "Prefetch {:?}", uri); try { cache.Prefetch(uri); } catch (...) { FmtError(cache_domain, - "Prefetch '{}' failed: {}", + "Prefetch {:?} failed: {}", uri, std::current_exception()); } } diff --git a/src/Permission.cxx b/src/Permission.cxx index cfacdbffd..d7d547188 100644 --- a/src/Permission.cxx +++ b/src/Permission.cxx @@ -52,7 +52,7 @@ ParsePermission(std::string_view s) if (s == i->name) return i->value; - throw FmtRuntimeError("unknown permission \"{}\"", s); + throw FmtRuntimeError("unknown permission {:?}", s); } static unsigned @@ -86,7 +86,7 @@ initPermissions(const ConfigData &config) const auto [password, permissions] = Split(value, PERMISSION_PASSWORD_CHAR); if (permissions.data() == nullptr) - throw FmtRuntimeError("\"{}\" not found in password string", + throw FmtRuntimeError("{:?} not found in password string", PERMISSION_PASSWORD_CHAR); permission_passwords.emplace(password, diff --git a/src/RemoteTagCache.cxx b/src/RemoteTagCache.cxx index 283ebf01f..70edc3dde 100644 --- a/src/RemoteTagCache.cxx +++ b/src/RemoteTagCache.cxx @@ -47,7 +47,7 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept item->scanner->Start(); } catch (...) { FmtError(remote_tag_cache_domain, - "Failed to scan tags of '{}': {}", + "Failed to scan tags of {:?}: {}", uri, std::current_exception()); item->scanner.reset(); @@ -113,7 +113,7 @@ void RemoteTagCache::Item::OnRemoteTagError(std::exception_ptr e) noexcept { FmtError(remote_tag_cache_domain, - "Failed to scan tags of '{}': {}", uri, e); + "Failed to scan tags of {:?}: {}", uri, e); scanner.reset(); diff --git a/src/archive/plugins/ZzipArchivePlugin.cxx b/src/archive/plugins/ZzipArchivePlugin.cxx index 3ba1d7a49..bbbb68c91 100644 --- a/src/archive/plugins/ZzipArchivePlugin.cxx +++ b/src/archive/plugins/ZzipArchivePlugin.cxx @@ -27,7 +27,7 @@ struct ZzipDir { explicit ZzipDir(Path path) :dir(zzip_dir_open(NarrowPath(path), nullptr)) { if (dir == nullptr) - throw FmtRuntimeError("Failed to open ZIP file {}", + throw FmtRuntimeError("Failed to open ZIP file {:?}", path); } @@ -120,11 +120,11 @@ ZzipArchiveFile::OpenStream(const char *pathname, const auto error = (zzip_error_t)zzip_error(dir->dir); switch (error) { case ZZIP_ENOENT: - throw FmtFileNotFound("Failed to open '{}' in ZIP file", + throw FmtFileNotFound("Failed to open {:?} in ZIP file", pathname); default: - throw FmtRuntimeError("Failed to open '{}' in ZIP file: {}", + throw FmtRuntimeError("Failed to open {:?} in ZIP file: {}", pathname, zzip_strerror(error)); } @@ -145,7 +145,7 @@ ZzipInputStream::Read(std::unique_lock &, void *ptr, size_t read_size) throw std::runtime_error("zzip_file_read() has failed"); if (nbytes == 0 && !IsEOF()) - throw FmtRuntimeError("Unexpected end of file {} at {} of {}", + throw FmtRuntimeError("Unexpected end of file {:?} at {} of {}", GetURI(), GetOffset(), GetSize()); offset = zzip_tell(file); diff --git a/src/client/Process.cxx b/src/client/Process.cxx index 3f11e0bf9..f463fcf1e 100644 --- a/src/client/Process.cxx +++ b/src/client/Process.cxx @@ -22,7 +22,7 @@ Client::ProcessCommandList(bool list_ok, for (auto &&i : list) { char *cmd = &*i.begin(); - FmtDebug(client_domain, "process command \"{}\"", cmd); + FmtDebug(client_domain, "process command {:?}", cmd); auto ret = command_process(*this, n++, cmd); FmtDebug(client_domain, "command returned {}", unsigned(ret)); if (IsExpired()) @@ -46,7 +46,7 @@ Client::ProcessLine(char *line) noexcept letter; this could be a badly routed HTTP request */ FmtWarning(client_domain, - "[{}] malformed command \"{}\"", + "[{}] malformed command {:?}", num, line); return CommandResult::CLOSE; } @@ -67,7 +67,7 @@ Client::ProcessLine(char *line) noexcept /* during idle mode, clients must not send anything except "noidle" */ FmtWarning(client_domain, - "[{}] command \"{}\" during idle", + "[{}] command {:?} during idle", num, line); return CommandResult::CLOSE; } @@ -116,7 +116,7 @@ Client::ProcessLine(char *line) noexcept const unsigned id = num; FmtDebug(client_domain, - "[{}] process command \"{}\"", + "[{}] process command {:?}", id, line); auto ret = command_process(*this, 0, line); FmtDebug(client_domain, diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index f1d869e90..f80c7443c 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -320,7 +320,7 @@ command_check_request(const struct command *cmd, Response &r, { if (cmd->permission != (permission & cmd->permission)) { r.FmtError(ACK_ERROR_PERMISSION, - FMT_STRING("you don't have permission for \"{}\""), + FMT_STRING("you don't have permission for {:?}"), cmd->cmd); return false; } @@ -333,17 +333,17 @@ command_check_request(const struct command *cmd, Response &r, if (min == max && unsigned(max) != args.size()) { r.FmtError(ACK_ERROR_ARG, - FMT_STRING("wrong number of arguments for \"{}\""), + FMT_STRING("wrong number of arguments for {:?}"), cmd->cmd); return false; } else if (args.size() < unsigned(min)) { r.FmtError(ACK_ERROR_ARG, - FMT_STRING("too few arguments for \"{}\""), + FMT_STRING("too few arguments for {:?}"), cmd->cmd); return false; } else if (max >= 0 && args.size() > unsigned(max)) { r.FmtError(ACK_ERROR_ARG, - FMT_STRING("too many arguments for \"{}\""), + FMT_STRING("too many arguments for {:?}"), cmd->cmd); return false; } else @@ -357,7 +357,7 @@ command_checked_lookup(Response &r, unsigned permission, const struct command *cmd = command_lookup(cmd_name); if (cmd == nullptr) { r.FmtError(ACK_ERROR_UNKNOWN, - FMT_STRING("unknown command \"{}\""), cmd_name); + FMT_STRING("unknown command {:?}"), cmd_name); return nullptr; } diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index 8b317cd1d..ea028ef92 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -325,7 +325,7 @@ handle_list(Client &client, Request args, Response &r) /* for compatibility with < 0.12.0 */ if (tagType != TAG_ALBUM) { r.FmtError(ACK_ERROR_ARG, - FMT_STRING("should be \"{}\" for 3 arguments"), + FMT_STRING("should be {:?} for 3 arguments"), tag_item_names[TAG_ALBUM]); return CommandResult::ERROR; } diff --git a/src/command/StickerCommands.cxx b/src/command/StickerCommands.cxx index f52aefdd5..33e843b0b 100644 --- a/src/command/StickerCommands.cxx +++ b/src/command/StickerCommands.cxx @@ -38,7 +38,7 @@ public: ValidateUri(uri).c_str(), name); if (value.empty()) { - response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: \"{}\"", name); + response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: {:?}", name); return CommandResult::ERROR; } @@ -63,7 +63,7 @@ public: ? sticker_database.Delete(sticker_type, uri) : sticker_database.DeleteValue(sticker_type, uri, name); if (!ret) { - response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: \"{}\"", name); + response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: {:?}", name); return CommandResult::ERROR; } @@ -247,13 +247,13 @@ public: protected: std::string ValidateUri(const char *uri) override { if (tag_type == TAG_NUM_OF_ITEM_TYPES) - throw std::invalid_argument(fmt::format("no such tag: \"{}\"", sticker_type)); + throw std::invalid_argument(fmt::format("no such tag: {:?}", sticker_type)); if (!sticker_allowed_tags.Test(tag_type)) - throw std::invalid_argument(fmt::format("unsupported tag: \"{}\"", sticker_type)); + throw std::invalid_argument(fmt::format("unsupported tag: {:?}", sticker_type)); if (!TagExists(database, tag_type, uri)) - throw std::invalid_argument(fmt::format("no such {}: \"{}\"", sticker_type, uri)); + throw std::invalid_argument(fmt::format("no such {}: {:?}", sticker_type, uri)); return {uri}; } @@ -283,7 +283,7 @@ protected: auto normalized = filter.ToExpression(); if (!FilterMatches(database, filter)) - throw std::invalid_argument(fmt::format("no matches found: \"{}\"", normalized)); + throw std::invalid_argument(fmt::format("no matches found: {:?}", normalized)); return normalized; } @@ -306,7 +306,7 @@ private: const ScopeDatabaseLock protect; if (!playlists.exists(uri)) - throw std::invalid_argument(fmt::format("no such playlist: \"{}\"", uri)); + throw std::invalid_argument(fmt::format("no such playlist: {:?}", uri)); return {uri}; } @@ -369,7 +369,7 @@ handle_sticker(Client &client, Request args, Response &r) handler = std::make_unique(r, db, sticker_database, tag_type); else { - r.FmtError(ACK_ERROR_ARG, "unknown sticker domain \"{}\"", sticker_type); + r.FmtError(ACK_ERROR_ARG, "unknown sticker domain {:?}", sticker_type); return CommandResult::ERROR; } @@ -413,7 +413,7 @@ handle_sticker(Client &client, Request args, Response &r) sort = s; } else { - r.FmtError(ACK_ERROR_ARG, "Unknown sort tag \"{}\"", s); + r.FmtError(ACK_ERROR_ARG, "Unknown sort tag {:?}", s); return CommandResult::ERROR; } @@ -444,7 +444,7 @@ handle_sticker(Client &client, Request args, Response &r) else if (StringIsEqual(op_s, "starts_with")) op = StickerOperator::STARTS_WITH; else { - r.FmtError(ACK_ERROR_ARG, "bad operator \"{}\"", op_s); + r.FmtError(ACK_ERROR_ARG, "bad operator {:?}", op_s); return CommandResult::ERROR; } } diff --git a/src/config/Block.cxx b/src/config/Block.cxx index 2e227d870..aa18b8f0c 100644 --- a/src/config/Block.cxx +++ b/src/config/Block.cxx @@ -12,7 +12,7 @@ void BlockParam::ThrowWithNested() const { - std::throw_with_nested(FmtRuntimeError("Error in setting \"{}\" on line {}", + std::throw_with_nested(FmtRuntimeError("Error in setting {:?} on line {}", name, line)); } diff --git a/src/config/Check.cxx b/src/config/Check.cxx index 75c075664..22b42c70a 100644 --- a/src/config/Check.cxx +++ b/src/config/Check.cxx @@ -18,7 +18,7 @@ Check(const ConfigBlock &block) for (const auto &i : block.block_params) { if (!i.used) FmtWarning(config_domain, - "option '{}' on line {} was not recognized", + "option {:?} on line {} was not recognized", i.name, i.line); } } diff --git a/src/config/Data.cxx b/src/config/Data.cxx index d8da9d2ed..202f2b674 100644 --- a/src/config/Data.cxx +++ b/src/config/Data.cxx @@ -141,7 +141,7 @@ ConfigData::FindBlock(ConfigBlockOption option, for (const auto &block : GetBlockList(option)) { const char *value2 = block.GetBlockValue(key); if (value2 == nullptr) - throw FmtRuntimeError("block without '{}' in line {}", + throw FmtRuntimeError("block without {:?} in line {}", key, block.line); if (StringIsEqual(value2, value)) diff --git a/src/config/File.cxx b/src/config/File.cxx index faa15fdf3..20bc08a3d 100644 --- a/src/config/File.cxx +++ b/src/config/File.cxx @@ -54,7 +54,7 @@ config_read_name_value(ConfigBlock &block, char *input, unsigned line) const BlockParam *bp = block.GetBlockParam(name); if (bp != nullptr) - throw FmtRuntimeError("\"{}\" is duplicate, first defined on line {}", + throw FmtRuntimeError("{:?} is duplicate, first defined on line {}", name, bp->line); block.AddBlockParam(name, value, line); @@ -102,12 +102,12 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader, if (option.deprecated) FmtWarning(config_file_domain, - "config parameter \"{}\" on line {} is deprecated", + "config parameter {:?} on line {} is deprecated", name, reader.GetLineNumber()); if (!option.repeatable) if (const auto *block = config_data.GetBlock(o)) - throw FmtRuntimeError("config parameter \"{}\" is first defined " + throw FmtRuntimeError("config parameter {:?} is first defined " "on line {} and redefined on line {}", name, block->line, reader.GetLineNumber()); @@ -134,7 +134,7 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader, if (option.deprecated) FmtWarning(config_file_domain, - "config parameter \"{}\" on line {} is deprecated", + "config parameter {:?} on line {} is deprecated", name, reader.GetLineNumber()); if (!option.repeatable) diff --git a/src/config/Parser.cxx b/src/config/Parser.cxx index 75d510eb7..554a76a34 100644 --- a/src/config/Parser.cxx +++ b/src/config/Parser.cxx @@ -20,7 +20,7 @@ ParseBool(const char *value) if (StringArrayContainsCase(f, value)) return false; - throw FmtRuntimeError(R"(Not a valid boolean ("yes" or "no"): "{}")", value); + throw FmtRuntimeError(R"(Not a valid boolean ("yes" or "no"): {:?})", value); } long diff --git a/src/config/PlayerConfig.cxx b/src/config/PlayerConfig.cxx index ce092288a..563a44918 100644 --- a/src/config/PlayerConfig.cxx +++ b/src/config/PlayerConfig.cxx @@ -22,7 +22,7 @@ GetBufferChunks(const ConfigData &config) buffer_size = param->With([](const char *s){ size_t result = ParseSize(s, KILOBYTE); if (result <= 0) - throw FmtRuntimeError("buffer size \"{}\" is not a " + throw FmtRuntimeError("buffer size {:?} is not a " "positive integer", s); if (result < MIN_BUFFER_SIZE) { @@ -37,7 +37,7 @@ GetBufferChunks(const ConfigData &config) unsigned buffer_chunks = buffer_size / CHUNK_SIZE; if (buffer_chunks >= 1 << 15) - throw FmtRuntimeError("buffer size \"{}\" is too big", + throw FmtRuntimeError("buffer size {:?} is too big", buffer_size); return buffer_chunks; diff --git a/src/db/DatabaseGlue.cxx b/src/db/DatabaseGlue.cxx index b6d2461cf..e5bfd93bd 100644 --- a/src/db/DatabaseGlue.cxx +++ b/src/db/DatabaseGlue.cxx @@ -19,14 +19,14 @@ DatabaseGlobalInit(EventLoop &main_event_loop, const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name); if (plugin == nullptr) - throw FmtRuntimeError("No such database plugin: {}", + throw FmtRuntimeError("No such database plugin: {:?}", plugin_name); try { return plugin->create(main_event_loop, io_event_loop, listener, block); } catch (...) { - std::throw_with_nested(FmtRuntimeError("Failed to initialize database plugin '{}'", + std::throw_with_nested(FmtRuntimeError("Failed to initialize database plugin {:?}", plugin_name)); } } diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 4c3108ee5..c9330366f 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -453,7 +453,7 @@ ProxyDatabase::Connect() std::throw_with_nested(host.empty() ? std::runtime_error("Failed to connect to remote MPD") - : FmtRuntimeError("Failed to connect to remote MPD '{}'", + : FmtRuntimeError("Failed to connect to remote MPD {:?}", host)); } diff --git a/src/db/plugins/simple/DatabaseSave.cxx b/src/db/plugins/simple/DatabaseSave.cxx index db44cf6ae..0d7ee6ada 100644 --- a/src/db/plugins/simple/DatabaseSave.cxx +++ b/src/db/plugins/simple/DatabaseSave.cxx @@ -90,7 +90,7 @@ db_load_internal(LineReader &file, Directory &music_root, if (*old_charset != 0 && strcmp(new_charset, old_charset) != 0) throw FmtRuntimeError("Existing database has charset " - "\"{}\" instead of \"{}\"; " + "{:?} instead of {:?}; " "discarding database file", new_charset, old_charset); } else if ((p = StringAfterPrefix(line, DB_TAG_PREFIX))) { @@ -100,13 +100,13 @@ db_load_internal(LineReader &file, Directory &music_root, const char *name = p; TagType tag = tag_name_parse(name); if (tag == TAG_NUM_OF_ITEM_TYPES) - throw FmtRuntimeError("Unrecognized tag '{}', " + throw FmtRuntimeError("Unrecognized tag {:?}, " "discarding database file", name); tags[tag] = true; } else { - throw FmtRuntimeError("Malformed line: {}", line); + throw FmtRuntimeError("Malformed line: {:?}", line); } } diff --git a/src/db/plugins/simple/DirectorySave.cxx b/src/db/plugins/simple/DirectorySave.cxx index 366c532e1..302bda62b 100644 --- a/src/db/plugins/simple/DirectorySave.cxx +++ b/src/db/plugins/simple/DirectorySave.cxx @@ -124,7 +124,7 @@ directory_load_subdir(LineReader &file, Directory &parent, std::string_view name break; if (!ParseLine(*directory, line)) - throw FmtRuntimeError("Malformed line: {}", line); + throw FmtRuntimeError("Malformed line: {:?}", line); } directory_load(file, *directory); @@ -153,7 +153,7 @@ directory_load(LineReader &file, Directory &directory) const std::string_view name = child->GetName(); if (!children.emplace(name).second) - throw FmtRuntimeError("Duplicate subdirectory '{}'", name); + throw FmtRuntimeError("Duplicate subdirectory {:?}", name); } else if ((p = StringAfterPrefix(line, SONG_BEGIN))) { const char *name = p; @@ -168,7 +168,7 @@ directory_load(LineReader &file, Directory &directory) song->in_playlist = in_playlist; if (!songs.emplace(song->filename).second) - throw FmtRuntimeError("Duplicate song '{}'", + throw FmtRuntimeError("Duplicate song {:?}", name); directory.AddSong(std::move(song)); @@ -176,7 +176,7 @@ directory_load(LineReader &file, Directory &directory) const char *name = p; playlist_metadata_load(file, directory.playlists, name); } else { - throw FmtRuntimeError("Malformed line: {}", line); + throw FmtRuntimeError("Malformed line: {:?}", line); } } } diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index d6d7a2cce..be3ab57e6 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -109,7 +109,7 @@ SimpleDatabase::Check() const #ifndef _WIN32 /* Check if we can write to the directory */ if (!CheckAccess(dirPath, X_OK | W_OK)) - throw FmtErrno("Can't create db file in \"{}\"", dirPath); + throw FmtErrno("Can't create db file in {:?}", dirPath); #endif return; @@ -124,7 +124,7 @@ SimpleDatabase::Check() const #ifndef _WIN32 /* And check that we can write to it */ if (!CheckAccess(path, R_OK | W_OK)) - throw FmtErrno("Can't open db file \"{}\" for reading/writing", + throw FmtErrno("Can't open db file {:?} for reading/writing", path); #endif } diff --git a/src/db/update/InotifyQueue.cxx b/src/db/update/InotifyQueue.cxx index 68dfafd6d..7dffafc2d 100644 --- a/src/db/update/InotifyQueue.cxx +++ b/src/db/update/InotifyQueue.cxx @@ -40,13 +40,13 @@ InotifyQueue::OnDelay() noexcept } } catch (...) { FmtError(update_domain, - "Failed to enqueue '{}': {}", + "Failed to enqueue {:?}: {}", uri_utf8, std::current_exception()); queue.pop_front(); continue; } - FmtDebug(inotify_domain, "updating '{}' job={}", + FmtDebug(inotify_domain, "updating {:?} job={}", uri_utf8, id); queue.pop_front(); diff --git a/src/db/update/Playlist.cxx b/src/db/update/Playlist.cxx index 7b3930801..253d00191 100644 --- a/src/db/update/Playlist.cxx +++ b/src/db/update/Playlist.cxx @@ -67,7 +67,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name, const auto uri_utf8 = storage.MapUTF8(directory->GetPath()); - FmtDebug(update_domain, "scanning playlist '{}'", uri_utf8); + FmtDebug(update_domain, "scanning playlist {:?}", uri_utf8); try { Mutex mutex; @@ -85,7 +85,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name, editor.LockDeleteDirectory(directory); } catch (...) { FmtError(update_domain, - "Failed to scan playlist '{}': {}", + "Failed to scan playlist {:?}: {}", uri_utf8, std::current_exception()); editor.LockDeleteDirectory(directory); } diff --git a/src/decoder/DecoderList.cxx b/src/decoder/DecoderList.cxx index d0c59c189..ebf37681d 100644 --- a/src/decoder/DecoderList.cxx +++ b/src/decoder/DecoderList.cxx @@ -145,10 +145,10 @@ decoder_plugin_init_all(const ConfigData &config) decoder_plugins_enabled[i] = true; } catch (const PluginUnavailable &e) { FmtError(decoder_domain, - "Decoder plugin '{}' is unavailable: {}", + "Decoder plugin {:?} is unavailable: {}", plugin.name, std::current_exception()); } catch (...) { - std::throw_with_nested(FmtRuntimeError("Failed to initialize decoder plugin '{}'", + std::throw_with_nested(FmtRuntimeError("Failed to initialize decoder plugin {:?}", plugin.name)); } } diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index a2a4a5b96..d6067ff3b 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -481,7 +481,7 @@ FfmpegDecode(DecoderClient &client, InputStream *input, const AVCodecDescriptor *codec_descriptor = avcodec_descriptor_get(codec_params.codec_id); if (codec_descriptor != nullptr) - FmtDebug(ffmpeg_domain, "codec '{}'", + FmtDebug(ffmpeg_domain, "codec {:?}", codec_descriptor->name); const AVCodec *codec = avcodec_find_decoder(codec_params.codec_id); @@ -590,10 +590,10 @@ ffmpeg_decode(DecoderClient &client, InputStream &input) const auto *input_format = format_context->iformat; if (input_format->long_name == nullptr) - FmtDebug(ffmpeg_domain, "detected input format '{}'", + FmtDebug(ffmpeg_domain, "detected input format {:?}", input_format->name); else - FmtDebug(ffmpeg_domain, "detected input format '{}' ({})", + FmtDebug(ffmpeg_domain, "detected input format {:?} ({:?})", input_format->name, input_format->long_name); FfmpegDecode(client, &input, *format_context); @@ -665,10 +665,10 @@ ffmpeg_uri_decode(DecoderClient &client, const char *uri) const auto *input_format = format_context->iformat; if (input_format->long_name == nullptr) - FmtDebug(ffmpeg_domain, "detected input format '{}'", + FmtDebug(ffmpeg_domain, "detected input format {:?}", input_format->name); else - FmtDebug(ffmpeg_domain, "detected input format '{}' ({})", + FmtDebug(ffmpeg_domain, "detected input format {:?} ({:?})", input_format->name, input_format->long_name); FfmpegDecode(client, nullptr, *format_context); diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index 4b7c26bc5..f867abaf3 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -142,7 +142,7 @@ gme_file_decode(DecoderClient &client, Path path_fs) AtScopeExit(emu) { gme_delete(emu); }; - FmtDebug(gme_domain, "emulator type '{}'", + FmtDebug(gme_domain, "emulator type {:?}", gme_type_system(gme_type(emu))); if (gme_accuracy >= 0) diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index f3687ef09..e4523fd4d 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -529,7 +529,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept &lame->version.major, &lame->version.minor) != 2) return false; - FmtDebug(mad_domain, "detected LAME version {}.{} (\"{}\")", + FmtDebug(mad_domain, "detected LAME version {}.{} ({:?})", lame->version.major, lame->version.minor, lame->encoder); /* The reference volume was changed from the 83dB used in the diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index 6e21735b9..2e58cc84b 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -62,7 +62,7 @@ static void loadRom(const Path rom_path, uint8_t *dump) { FileReader romDump(rom_path); if (romDump.Read(std::as_writable_bytes(std::span{dump, rom_size})) != rom_size) - throw FmtRuntimeError("Could not load rom dump '{}'", rom_path); + throw FmtRuntimeError("Could not load rom dump {:?}", rom_path); } /** @@ -74,7 +74,7 @@ sidplay_load_songlength_db(const Path path) auto db = std::make_unique(); bool error = !db->open(path.c_str()); if (error) - throw FmtRuntimeError("unable to read songlengths file {}: {}", + throw FmtRuntimeError("unable to read songlengths file {:?}: {}", path, db->error()); return db; diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index 707333a8a..1ce2b1a64 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -41,7 +41,7 @@ WavpackOpenInput(Path path, int flags, int norm_offset) auto wpc = WavpackOpenFileInput(np, error, flags, norm_offset); if (wpc == nullptr) - throw FmtRuntimeError("failed to open WavPack file \"{}\": {}", + throw FmtRuntimeError("failed to open WavPack file {:?}: {}", path, error); return wpc; diff --git a/src/encoder/plugins/LameEncoderPlugin.cxx b/src/encoder/plugins/LameEncoderPlugin.cxx index 05e28d93f..ced087cd9 100644 --- a/src/encoder/plugins/LameEncoderPlugin.cxx +++ b/src/encoder/plugins/LameEncoderPlugin.cxx @@ -63,7 +63,7 @@ PreparedLameEncoder::PreparedLameEncoder(const ConfigBlock &block) quality = float(ParseDouble(value, &endptr)); if (*endptr != '\0' || quality < -1.0f || quality > 10.0f) - throw FmtRuntimeError("quality \"{}\" is not a number in the " + throw FmtRuntimeError("quality {:?} is not a number in the " "range -1 to 10", value); diff --git a/src/encoder/plugins/TwolameEncoderPlugin.cxx b/src/encoder/plugins/TwolameEncoderPlugin.cxx index 3c2cc2c68..2463c411f 100644 --- a/src/encoder/plugins/TwolameEncoderPlugin.cxx +++ b/src/encoder/plugins/TwolameEncoderPlugin.cxx @@ -80,7 +80,7 @@ PreparedTwolameEncoder::PreparedTwolameEncoder(const ConfigBlock &block) quality = float(ParseDouble(value, &endptr)); if (*endptr != '\0' || quality < -1.0f || quality > 10.0f) - throw FmtRuntimeError("quality \"{}\" is not a number in the " + throw FmtRuntimeError("quality {:?} is not a number in the " "range -1 to 10", value); diff --git a/src/encoder/plugins/VorbisEncoderPlugin.cxx b/src/encoder/plugins/VorbisEncoderPlugin.cxx index e120b2351..7d0cd824f 100644 --- a/src/encoder/plugins/VorbisEncoderPlugin.cxx +++ b/src/encoder/plugins/VorbisEncoderPlugin.cxx @@ -73,7 +73,7 @@ PreparedVorbisEncoder::PreparedVorbisEncoder(const ConfigBlock &block) quality = ParseDouble(value, &endptr); if (*endptr != '\0' || quality < -1.0f || quality > 10.0f) - throw FmtRuntimeError("quality \"{}\" is not a number in the " + throw FmtRuntimeError("quality {:?} is not a number in the " "range -1 to 10", value); diff --git a/src/filter/plugins/TwoFilters.cxx b/src/filter/plugins/TwoFilters.cxx index dca6cbb0f..b93eba416 100644 --- a/src/filter/plugins/TwoFilters.cxx +++ b/src/filter/plugins/TwoFilters.cxx @@ -35,7 +35,7 @@ PreparedTwoFilters::Open(AudioFormat &audio_format) auto b = second->Open(b_in_format); if (b_in_format != a_out_format) - throw FmtRuntimeError("Audio format not supported by filter '{}': {}", + throw FmtRuntimeError("Audio format not supported by filter {:?}: {}", second_name, a_out_format); return std::make_unique(std::move(a), diff --git a/src/input/Init.cxx b/src/input/Init.cxx index 8148d2bac..cb6ed2366 100644 --- a/src/input/Init.cxx +++ b/src/input/Init.cxx @@ -55,16 +55,16 @@ input_stream_global_init(const ConfigData &config, EventLoop &event_loop) input_plugins_enabled[i] = true; } catch (const PluginUnconfigured &e) { FmtDebug(input_domain, - "Input plugin '{}' is not configured: {}", + "Input plugin {:?} is not configured: {}", plugin->name, e.what()); continue; } catch (const PluginUnavailable &e) { FmtDebug(input_domain, - "Input plugin '{}' is unavailable: {}", + "Input plugin {:?} is unavailable: {}", plugin->name, e.what()); continue; } catch (...) { - std::throw_with_nested(FmtRuntimeError("Failed to initialize input plugin '{}'", + std::throw_with_nested(FmtRuntimeError("Failed to initialize input plugin {:?}", plugin->name)); } } diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx index 60cedbf4a..6ed7da7a7 100644 --- a/src/input/plugins/AlsaInputPlugin.cxx +++ b/src/input/plugins/AlsaInputPlugin.cxx @@ -256,13 +256,13 @@ AlsaInputStream::Recover(int err) switch(err) { case -EPIPE: FmtDebug(alsa_input_domain, - "Overrun on ALSA capture device \"{}\"", + "Overrun on ALSA capture device {:?}", device); break; case -ESTRPIPE: FmtDebug(alsa_input_domain, - "ALSA capture device \"{}\" was suspended", + "ALSA capture device {:?} was suspended", device); break; } diff --git a/src/input/plugins/ArchiveInputPlugin.cxx b/src/input/plugins/ArchiveInputPlugin.cxx index ee080cc63..749f7fde6 100644 --- a/src/input/plugins/ArchiveInputPlugin.cxx +++ b/src/input/plugins/ArchiveInputPlugin.cxx @@ -28,7 +28,7 @@ OpenArchiveInputStream(Path path, Mutex &mutex) } } catch (...) { FmtDebug(input_domain, - "not an archive, lookup '{}' failed: {}", + "not an archive, lookup {:?} failed: {}", path, std::current_exception()); return nullptr; } diff --git a/src/lib/ffmpeg/Filter.cxx b/src/lib/ffmpeg/Filter.cxx index 5525f859d..52373ba52 100644 --- a/src/lib/ffmpeg/Filter.cxx +++ b/src/lib/ffmpeg/Filter.cxx @@ -17,7 +17,7 @@ RequireFilterByName(const char *name) { const auto *filter = avfilter_get_by_name(name); if (filter == nullptr) - throw FmtRuntimeError("No such FFmpeg filter: '{}'", name); + throw FmtRuntimeError("No such FFmpeg filter: {:?}", name); return *filter; } diff --git a/src/lib/icu/Converter.cxx b/src/lib/icu/Converter.cxx index 62b8fc8cd..b8264e369 100644 --- a/src/lib/icu/Converter.cxx +++ b/src/lib/icu/Converter.cxx @@ -41,7 +41,7 @@ IcuConverter::Create(const char *charset) UConverter *converter = ucnv_open(charset, &code); if (converter == nullptr) throw ICU::MakeError(code, - FmtBuffer<256>(FMT_STRING("Failed to initialize charset '{}'"), + FmtBuffer<256>(FMT_STRING("Failed to initialize charset {:?}"), charset)); return std::unique_ptr(new IcuConverter(converter)); @@ -54,7 +54,7 @@ IcuConverter::Create(const char *charset) iconv_close(to); if (from != (iconv_t)-1) iconv_close(from); - throw FmtErrno(e, FMT_STRING("Failed to initialize charset '{}'"), + throw FmtErrno(e, FMT_STRING("Failed to initialize charset {:?}"), charset); } diff --git a/src/lib/sqlite/Database.cxx b/src/lib/sqlite/Database.cxx index bbafb02a0..d2ca32bc7 100644 --- a/src/lib/sqlite/Database.cxx +++ b/src/lib/sqlite/Database.cxx @@ -12,7 +12,7 @@ Database::Database(const char *path) int result = sqlite3_open(path, &db); if (result != SQLITE_OK) throw SqliteError(db, result, - FmtBuffer<1024>("Failed to open sqlite database '{}'", + FmtBuffer<1024>("Failed to open sqlite database {:?}", path)); } diff --git a/src/mixer/All.cxx b/src/mixer/All.cxx index 04c29d326..22fda6b2e 100644 --- a/src/mixer/All.cxx +++ b/src/mixer/All.cxx @@ -33,7 +33,7 @@ output_mixer_get_volume(const AudioOutputControl &ao) noexcept return mixer->LockGetVolume(); } catch (...) { FmtError(mixer_domain, - "Failed to read mixer for '{}': {}", + "Failed to read mixer for {:?}: {}", ao.GetName(), std::current_exception()); return -1; } @@ -88,9 +88,9 @@ output_mixer_set_volume(AudioOutputControl &ao, unsigned volume) return SetVolumeResult::OK; } catch (...) { FmtError(mixer_domain, - "Failed to set mixer for '{}': {}", + "Failed to set mixer for {:?}: {}", ao.GetName(), std::current_exception()); - std::throw_with_nested(std::runtime_error(FmtBuffer<256>("Failed to set mixer for '{}'", + std::throw_with_nested(std::runtime_error(FmtBuffer<256>("Failed to set mixer for {:?}", ao.GetName()))); } } diff --git a/src/mixer/plugins/OssMixerPlugin.cxx b/src/mixer/plugins/OssMixerPlugin.cxx index a9756bc9d..5e3f94bcf 100644 --- a/src/mixer/plugins/OssMixerPlugin.cxx +++ b/src/mixer/plugins/OssMixerPlugin.cxx @@ -108,7 +108,7 @@ OssMixer::Open() throw MakeErrno("READ_DEVMASK failed"); if (((1 << volume_control) & devmask) == 0) - throw FmtErrno("mixer control \"{}\" not usable", + throw FmtErrno("mixer control {:?} not usable", control); } } catch (...) { @@ -134,8 +134,8 @@ OssMixer::GetVolume() if (left != right) { FmtWarning(oss_mixer_domain, - "volume for left and right is not the same, \"{}\" and " - "\"{}\"\n", left, right); + "volume for left and right is not the same, {:?} and " + "{:?}\n", left, right); } return left; diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx index 8180313a6..5058a1f2b 100644 --- a/src/mixer/plugins/PulseMixerPlugin.cxx +++ b/src/mixer/plugins/PulseMixerPlugin.cxx @@ -161,7 +161,7 @@ parse_volume_scale_factor(const char *value) { float factor = ParseFloat(value, &endptr); if (endptr == value || *endptr != '\0' || factor < 0.5f || factor > 5.0f) - throw FmtRuntimeError("\"{}\" is not a number in the " + throw FmtRuntimeError("{:?} is not a number in the " "range 0.5 to 5.0", value); diff --git a/src/neighbor/Glue.cxx b/src/neighbor/Glue.cxx index 8aebb9a35..52785025b 100644 --- a/src/neighbor/Glue.cxx +++ b/src/neighbor/Glue.cxx @@ -22,7 +22,7 @@ CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener, { const NeighborPlugin *plugin = GetNeighborPluginByName(plugin_name); if (plugin == nullptr) - throw FmtRuntimeError("No such neighbor plugin: {}", + throw FmtRuntimeError("No such neighbor plugin: {:?}", plugin_name); return plugin->create(loop, listener, block); @@ -56,7 +56,7 @@ NeighborGlue::Open() for (auto k = explorers.begin(); k != i; ++k) k->explorer->Close(); - std::throw_with_nested(FmtRuntimeError("Failed to open neighblor plugin '{}'", + std::throw_with_nested(FmtRuntimeError("Failed to open neighblor plugin {:?}", i->name)); } } diff --git a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx index c69484c5f..e665965ca 100644 --- a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx +++ b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx @@ -151,7 +151,7 @@ ReadServers(SmbclientContext &ctx, const char *uri, ReadServers(ctx, handle, list); ctx.CloseDirectory(handle); } else - FmtError(smbclient_domain, "smbc_opendir('{}') failed: {}", + FmtError(smbclient_domain, "smbc_opendir({:?}) failed: {}", uri, strerror(errno)); } diff --git a/src/output/Control.cxx b/src/output/Control.cxx index cf10aeb2a..a034df91d 100644 --- a/src/output/Control.cxx +++ b/src/output/Control.cxx @@ -268,7 +268,7 @@ AudioOutputControl::Open(std::unique_lock &lock, output->mixer->LockOpen(); } catch (...) { FmtError(output_domain, - "Failed to open mixer for '{}': {}", + "Failed to open mixer for {:?}: {}", GetName(), std::current_exception()); } } diff --git a/src/output/Init.cxx b/src/output/Init.cxx index 1b94e39ad..4277671bd 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -56,7 +56,7 @@ audio_output_detect() continue; FmtInfo(output_domain, - "Attempting to detect a {} audio device", + "Attempting to detect a {:?} audio device", plugin->name); if (ao_plugin_test_default_device(plugin)) return plugin; @@ -154,7 +154,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block, config_audio_format.Clear(); } - log_name = fmt::format("\"{}\" ({})", name, plugin_name); + log_name = fmt::format("{:?} ({})", name, plugin_name); /* create the normalization filter (if configured) */ @@ -173,7 +173,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block, has been set up already and even an empty one will work (if only with unexpected behaviour) */ FmtError(output_domain, - "Failed to initialize filter chain for '{}': {}", + "Failed to initialize filter chain for {:?}: {}", name, std::current_exception()); } } @@ -223,7 +223,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop, mixer_listener); } catch (...) { FmtError(output_domain, - "Failed to initialize hardware mixer for '{}': {}", + "Failed to initialize hardware mixer for {:?}: {}", name, std::current_exception()); } @@ -235,7 +235,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop, mixer, 100); else FmtError(output_domain, - "No such mixer for output '{}'", name); + "No such mixer for output {:?}", name); } else if (!StringIsEqual(replay_gain_handler, "software") && prepared_replay_gain_filter != nullptr) { throw std::runtime_error("Invalid \"replay_gain_handler\" value"); diff --git a/src/output/State.cxx b/src/output/State.cxx index ed990ab27..89191c571 100644 --- a/src/output/State.cxx +++ b/src/output/State.cxx @@ -57,7 +57,7 @@ audio_output_state_read(const char *line, MultipleOutputs &outputs) auto *ao = outputs.FindByName(name); if (ao == nullptr) { FmtDebug(output_domain, - "Ignoring device state for '{}'", name); + "Ignoring device state for {:?}", name); return true; } diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 15a51b758..b857d1476 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -792,14 +792,14 @@ AlsaOutput::Open(AudioFormat &audio_format) SND_PCM_STREAM_PLAYBACK, mode); if (err < 0) throw Alsa::MakeError(err, - FmtBuffer<256>("Failed to open ALSA device \"{}\"", + FmtBuffer<256>("Failed to open ALSA device {:?}", GetDevice())); const char *pcm_name = snd_pcm_name(pcm); if (pcm_name == nullptr) pcm_name = "?"; - FmtDebug(alsa_output_domain, "opened {} type={}", + FmtDebug(alsa_output_domain, "opened {:?} type={}", pcm_name, snd_pcm_type_name(snd_pcm_type(pcm))); @@ -830,7 +830,7 @@ AlsaOutput::Open(AudioFormat &audio_format) ); } catch (...) { snd_pcm_close(pcm); - std::throw_with_nested(FmtRuntimeError("Error opening ALSA device \"{}\"", + std::throw_with_nested(FmtRuntimeError("Error opening ALSA device {:?}", GetDevice())); } @@ -891,11 +891,11 @@ AlsaOutput::Recover(int err) noexcept { if (err == -EPIPE) { FmtDebug(alsa_output_domain, - "Underrun on ALSA device \"{}\"", + "Underrun on ALSA device {:?}", GetDevice()); } else if (err == -ESTRPIPE) { FmtDebug(alsa_output_domain, - "ALSA device \"{}\" was suspended", + "ALSA device {:?} was suspended", GetDevice()); } diff --git a/src/output/plugins/AoOutputPlugin.cxx b/src/output/plugins/AoOutputPlugin.cxx index 0cb959ce9..a98b625e4 100644 --- a/src/output/plugins/AoOutputPlugin.cxx +++ b/src/output/plugins/AoOutputPlugin.cxx @@ -105,14 +105,14 @@ AoOutput::AoOutput(const ConfigBlock &block) driver = ao_driver_id(value); if (driver < 0) - throw FmtRuntimeError("\"{}\" is not a valid ao driver", + throw FmtRuntimeError("{:?} is not a valid ao driver", value); ao_info *ai = ao_driver_info(driver); if (ai == nullptr) throw std::runtime_error("problems getting driver info"); - FmtDebug(ao_output_domain, "using ao driver \"{}\" for \"{}\"\n", + FmtDebug(ao_output_domain, "using ao driver {:?} for {:?}\n", ai->short_name, block.GetBlockValue("name", nullptr)); value = block.GetBlockValue("options", nullptr); @@ -120,7 +120,7 @@ AoOutput::AoOutput(const ConfigBlock &block) for (const std::string_view i : IterableSplitString(value, ';')) { const auto [n, v] = Split(Strip(i), '='); if (n.empty() || v.data() == nullptr) - throw FmtRuntimeError("problems parsing option \"{}\"", + throw FmtRuntimeError("problems parsing option {:?}", i); ao_append_option(&options, std::string{n}.c_str(), diff --git a/src/output/plugins/FifoOutputPlugin.cxx b/src/output/plugins/FifoOutputPlugin.cxx index 69b3b1c35..671dc5be3 100644 --- a/src/output/plugins/FifoOutputPlugin.cxx +++ b/src/output/plugins/FifoOutputPlugin.cxx @@ -74,7 +74,7 @@ inline void FifoOutput::Delete() { FmtDebug(fifo_output_domain, - "Removing FIFO \"{}\"", path); + "Removing FIFO {:?}", path); try { RemoveFile(path); @@ -108,7 +108,7 @@ inline void FifoOutput::Create() { if (!MakeFifo(path, 0666)) - throw FmtErrno("Couldn't create FIFO \"{}\"", path); + throw FmtErrno("Couldn't create FIFO {:?}", path); created = true; } @@ -124,11 +124,11 @@ FifoOutput::Check() return; } - throw FmtErrno("Failed to stat FIFO \"{}\"", path); + throw FmtErrno("Failed to stat FIFO {:?}", path); } if (!S_ISFIFO(st.st_mode)) - throw FmtRuntimeError("\"{}\" already exists, but is not a FIFO", + throw FmtRuntimeError("{:?} already exists, but is not a FIFO", path); } @@ -139,12 +139,12 @@ try { input = OpenFile(path, O_RDONLY|O_NONBLOCK|O_BINARY, 0).Steal(); if (input < 0) - throw FmtErrno("Could not open FIFO \"{}\" for reading", + throw FmtErrno("Could not open FIFO {:?} for reading", path); output = OpenFile(path, O_WRONLY|O_NONBLOCK|O_BINARY, 0).Steal(); if (output < 0) - throw FmtErrno("Could not open FIFO \"{}\" for writing"); + throw FmtErrno("Could not open FIFO {:?} for writing"); } catch (...) { CloseFifo(); throw; @@ -175,7 +175,7 @@ FifoOutput::Cancel() noexcept if (bytes < 0 && errno != EAGAIN) { FmtError(fifo_output_domain, - "Flush of FIFO \"{}\" failed: {}", + "Flush of FIFO {:?} failed: {}", path, strerror(errno)); } } diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index f9904f742..8f33c71ee 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -410,7 +410,7 @@ JackOutput::Connect() portflags, 0); if (ports[i] == nullptr) { Disconnect(); - throw FmtRuntimeError("Cannot register output port \"{}\"", + throw FmtRuntimeError("Cannot register output port {:?}", source_ports[i]); } } @@ -521,7 +521,7 @@ JackOutput::Start() jports[num_dports] != nullptr; ++num_dports) { FmtDebug(jack_output_domain, - "destination_port[{}] = '{}'\n", + "destination_port[{}] = {:?}\n", num_dports, jports[num_dports]); dports[num_dports] = jports[num_dports]; } diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index ef40fb883..cc8d70b32 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -260,7 +260,7 @@ osx_output_parse_channel_map(const char *device_name, continue; } - throw FmtRuntimeError("{}: invalid character '{}' in channel map", + throw FmtRuntimeError("{}: invalid character {:?} in channel map", device_name, *channel_map_str); } @@ -567,7 +567,7 @@ FindAudioDeviceByName(const char *name) return id; } - throw FmtRuntimeError("Found no audio device names '{}'", name); + throw FmtRuntimeError("Found no audio device names {:?}", name); } static void diff --git a/src/output/plugins/OpenALOutputPlugin.cxx b/src/output/plugins/OpenALOutputPlugin.cxx index 735533a19..62d114369 100644 --- a/src/output/plugins/OpenALOutputPlugin.cxx +++ b/src/output/plugins/OpenALOutputPlugin.cxx @@ -110,13 +110,13 @@ OpenALOutput::SetupContext() { device = alcOpenDevice(device_name); if (device == nullptr) - throw FmtRuntimeError("Error opening OpenAL device \"{}\"", + throw FmtRuntimeError("Error opening OpenAL device {:?}", device_name); context = alcCreateContext(device, nullptr); if (context == nullptr) { alcCloseDevice(device); - throw FmtRuntimeError("Error creating context for \"{}\"", + throw FmtRuntimeError("Error creating context for {:?}", device_name); } } diff --git a/src/output/plugins/OssOutputPlugin.cxx b/src/output/plugins/OssOutputPlugin.cxx index 7b6a8f981..f517d0edf 100644 --- a/src/output/plugins/OssOutputPlugin.cxx +++ b/src/output/plugins/OssOutputPlugin.cxx @@ -166,7 +166,7 @@ oss_output_test_default_device() noexcept return true; FmtError(oss_output_domain, - "Error opening OSS device \"{}\": {}", + "Error opening OSS device {:?}: {}", default_devices[i], strerror(errno)); } @@ -621,7 +621,7 @@ try { assert(!fd.IsDefined()); if (!fd.Open(device, O_WRONLY)) - throw FmtErrno("Error opening OSS device \"{}\"", device); + throw FmtErrno("Error opening OSS device {:?}", device); OssIoctlExact(fd, SNDCTL_DSP_CHANNELS, effective_channels, "Failed to set channel count"); @@ -638,7 +638,7 @@ void OssOutput::Open(AudioFormat &_audio_format) try { if (!fd.Open(device, O_WRONLY)) - throw FmtErrno("Error opening OSS device \"{}\"", device); + throw FmtErrno("Error opening OSS device {:?}", device); SetupOrDop(_audio_format); } catch (...) { @@ -676,7 +676,7 @@ OssOutput::Play(std::span src) return pcm_export->CalcInputSize(ret); if (ret < 0 && errno != EINTR) - throw FmtErrno("Write error on {}", device); + throw FmtErrno("Write error on {:?}", device); } } diff --git a/src/output/plugins/PipeOutputPlugin.cxx b/src/output/plugins/PipeOutputPlugin.cxx index 3a1e38d96..1a45c809c 100644 --- a/src/output/plugins/PipeOutputPlugin.cxx +++ b/src/output/plugins/PipeOutputPlugin.cxx @@ -45,7 +45,7 @@ PipeOutput::Open([[maybe_unused]] AudioFormat &audio_format) { fh = popen(cmd.c_str(), "w"); if (fh == nullptr) - throw FmtErrno("Error opening pipe \"{}\"", cmd); + throw FmtErrno("Error opening pipe {:?}", cmd); } std::size_t diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx index 300956f7f..7fc0862e9 100644 --- a/src/output/plugins/RecorderOutputPlugin.cxx +++ b/src/output/plugins/RecorderOutputPlugin.cxx @@ -261,7 +261,7 @@ RecorderOutput::ReopenFormat(AllocatedPath &&new_path) path = std::move(new_path); file = new_file; - FmtDebug(recorder_domain, "Recording to \"{}\"", path); + FmtDebug(recorder_domain, "Recording to {:?}", path); } void diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 6aeb5917c..90fbc8327 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -88,7 +88,7 @@ require_block_string(const ConfigBlock &block, const char *name) { const char *value = block.GetBlockValue(name); if (value == nullptr) - throw FmtRuntimeError("no \"{}\" defined for shout device defined " + throw FmtRuntimeError("no {:?} defined for shout device defined " "at line {}\n", name, block.line); return value; @@ -123,7 +123,7 @@ ParseShoutTls(const char *value) else if (StringIsEqual(value, "rfc2817")) return SHOUT_TLS_RFC2817; else - throw FmtRuntimeError("invalid shout TLS option \"{}\"", + throw FmtRuntimeError("invalid shout TLS option {:?}", value); } @@ -146,7 +146,7 @@ ParseShoutProtocol(const char *value, const char *mime_type) if (StringIsEqual(value, "shoutcast")) { if (!StringIsEqual(mime_type, "audio/mpeg")) - throw FmtRuntimeError("you cannot stream \"{}\" to shoutcast, use mp3", + throw FmtRuntimeError("you cannot stream {:?} to shoutcast, use mp3", mime_type); return SHOUT_PROTOCOL_ICY; } else if (StringIsEqual(value, "icecast1")) @@ -154,7 +154,7 @@ ParseShoutProtocol(const char *value, const char *mime_type) else if (StringIsEqual(value, "icecast2")) return SHOUT_PROTOCOL_HTTP; else - throw FmtRuntimeError("shout protocol \"{}\" is not \"shoutcast\" or " + throw FmtRuntimeError("shout protocol {:?} is not \"shoutcast\" or " "\"icecast1\"or \"icecast2\"", value); } diff --git a/src/output/plugins/WinmmOutputPlugin.cxx b/src/output/plugins/WinmmOutputPlugin.cxx index 1133978c4..df2eeb1f3 100644 --- a/src/output/plugins/WinmmOutputPlugin.cxx +++ b/src/output/plugins/WinmmOutputPlugin.cxx @@ -106,7 +106,7 @@ get_device_id(const char *device_name) UINT id = strtoul(device_name, &endptr, 0); if (endptr > device_name && *endptr == 0) { if (id >= numdevs) - throw FmtRuntimeError("device \"{}\" is not found", + throw FmtRuntimeError("device {:?} is not found", device_name); return id; @@ -127,7 +127,7 @@ get_device_id(const char *device_name) return i; } - throw FmtRuntimeError("device \"{}\" is not found", device_name); + throw FmtRuntimeError("device {:?} is not found", device_name); } WinmmOutput::WinmmOutput(const ConfigBlock &block) diff --git a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx index af16c264d..fcc0d5320 100644 --- a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx +++ b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx @@ -789,7 +789,7 @@ WasapiOutput::ChooseDevice() if (!SafeSilenceTry([this, &id]() { id = std::stoul(device_config); })) { device = SearchDevice(*enumerator, device_config); if (!device) - throw FmtRuntimeError("Device '{}' not found", + throw FmtRuntimeError("Device {:?} not found", device_config); } else device = GetDevice(*enumerator, id); @@ -1007,7 +1007,7 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator) continue; FmtNotice(wasapi_output_domain, - "Device \"{}\" \"{}\"", i, name.c_str()); + "Device {:?} {:?}", i, name.c_str()); } } diff --git a/src/pcm/LibsamplerateResampler.cxx b/src/pcm/LibsamplerateResampler.cxx index 04b28da74..d7fdf3e96 100644 --- a/src/pcm/LibsamplerateResampler.cxx +++ b/src/pcm/LibsamplerateResampler.cxx @@ -53,11 +53,11 @@ pcm_resample_lsr_global_init(const ConfigBlock &block) { const char *converter = block.GetBlockValue("type", "2"); if (!lsr_parse_converter(converter)) - throw FmtRuntimeError("unknown samplerate converter '{}'", + throw FmtRuntimeError("unknown samplerate converter {:?}", converter); FmtDebug(libsamplerate_domain, - "libsamplerate converter '{}'", + "libsamplerate converter {:?}", src_get_name(lsr_converter)); } diff --git a/src/pcm/SoxrResampler.cxx b/src/pcm/SoxrResampler.cxx index 85dd0ec26..1ae0e7569 100644 --- a/src/pcm/SoxrResampler.cxx +++ b/src/pcm/SoxrResampler.cxx @@ -153,7 +153,7 @@ pcm_resample_soxr_global_init(const ConfigBlock &block) if (recipe == SOXR_INVALID_RECIPE) { assert(quality_string != nullptr); - throw FmtRuntimeError("unknown quality setting '{}' in line {}", + throw FmtRuntimeError("unknown quality setting {:?} in line {}", quality_string, block.line); } else if (recipe == SOXR_CUSTOM_RECIPE) { // used to preset possible internal flags, like SOXR_RESET_ON_CLEAR @@ -177,7 +177,7 @@ pcm_resample_soxr_global_init(const ConfigBlock &block) soxr_quality = soxr_quality_spec(recipe, 0); } - FmtDebug(soxr_domain, "soxr converter '{}'", + FmtDebug(soxr_domain, "soxr converter {:?}", soxr_quality_name(recipe)); const unsigned n_threads = block.GetBlockValue("threads", 1); @@ -202,7 +202,7 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate) throw FmtRuntimeError("soxr initialization has failed: {}", e); - FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr)); + FmtDebug(soxr_domain, "soxr engine {:?}", soxr_engine(soxr)); if (soxr_use_custom_recipe) FmtDebug(soxr_domain, "soxr precision={:0.0f}, phase_response={:0.2f}, " diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 297920524..c92ce3d85 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -623,7 +623,7 @@ Player::CheckDecoderStartup(std::unique_lock &lock) noexcept if (!paused && !OpenOutput()) { FmtError(player_domain, "problems opening audio device " - "while playing \"{}\"", + "while playing {:?}", dc.song->GetURI()); return true; } @@ -1065,7 +1065,7 @@ Player::SongBorder() noexcept { const ScopeUnlock unlock(pc.mutex); - FmtNotice(player_domain, "played \"{}\"", song->GetURI()); + FmtNotice(player_domain, "played {:?}", song->GetURI()); ReplacePipe(dc.pipe); @@ -1211,7 +1211,7 @@ Player::Run() noexcept cross_fade_tag.reset(); if (song != nullptr) { - FmtNotice(player_domain, "played \"{}\"", song->GetURI()); + FmtNotice(player_domain, "played {:?}", song->GetURI()); song.reset(); } diff --git a/src/playlist/PlaylistQueue.cxx b/src/playlist/PlaylistQueue.cxx index ee3d3b4b0..1f382ce93 100644 --- a/src/playlist/PlaylistQueue.cxx +++ b/src/playlist/PlaylistQueue.cxx @@ -45,7 +45,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e, loader)) { failures += 1; if (failures < max_log_msgs) { - FmtError(playlist_domain, "Failed to load \"{}\".", song->GetURI()); + FmtError(playlist_domain, "Failed to load {:?}.", song->GetURI()); } else if (failures == max_log_msgs) { LogError(playlist_domain, "Further errors for this playlist will not be logged."); } diff --git a/src/queue/Playlist.cxx b/src/queue/Playlist.cxx index 2c794f682..6c34096e7 100644 --- a/src/queue/Playlist.cxx +++ b/src/queue/Playlist.cxx @@ -56,7 +56,7 @@ playlist::QueueSongOrder(PlayerControl &pc, unsigned order) noexcept const DetachedSong &song = queue.GetOrder(order); - FmtDebug(playlist_domain, "queue song {}:\"{}\"", + FmtDebug(playlist_domain, "queue song {}:{:?}", queued, song.GetURI()); pc.LockEnqueueSong(std::make_unique(song)); @@ -168,7 +168,7 @@ playlist::PlayOrder(PlayerControl &pc, unsigned order) const DetachedSong &song = queue.GetOrder(order); - FmtDebug(playlist_domain, "play {}:\"{}\"", order, song.GetURI()); + FmtDebug(playlist_domain, "play {}:{:?}", order, song.GetURI()); current = order; diff --git a/src/storage/plugins/UdisksStorage.cxx b/src/storage/plugins/UdisksStorage.cxx index 31aa245e1..df2d4dadd 100644 --- a/src/storage/plugins/UdisksStorage.cxx +++ b/src/storage/plugins/UdisksStorage.cxx @@ -76,7 +76,7 @@ public: UnmountWait(); } catch (...) { FmtError(udisks_domain, - "Failed to unmount '{}': {}", + "Failed to unmount {:?}: {}", base_uri, std::current_exception()); } } diff --git a/src/tag/Config.cxx b/src/tag/Config.cxx index 0b334adaa..6499f3570 100644 --- a/src/tag/Config.cxx +++ b/src/tag/Config.cxx @@ -44,7 +44,7 @@ TagLoadConfig(const ConfigData &config) const auto type = tag_name_parse_i(name); if (type == TAG_NUM_OF_ITEM_TYPES) - throw FmtRuntimeError("error parsing metadata item \"{}\"", + throw FmtRuntimeError("error parsing metadata item {:?}", name); if (plus) diff --git a/src/unix/Daemon.cxx b/src/unix/Daemon.cxx index d74aa33e3..c9e3a73c6 100644 --- a/src/unix/Daemon.cxx +++ b/src/unix/Daemon.cxx @@ -56,7 +56,7 @@ daemonize_kill() const pid_t pid = ReadPidFile(pidfile); if (pid < 0) - throw FmtErrno("unable to read the pid from file \"{}\"", + throw FmtErrno("unable to read the pid from file {:?}", pidfile); if (kill(pid, SIGTERM) < 0) @@ -94,7 +94,7 @@ daemonize_set_user() user_uid != getuid() && initgroups(user_name, user_gid) == -1) { throw FmtErrno("Failed to set supplementary groups " - "of user \"{}\"", + "of user {:?}", user_name); } #endif @@ -102,7 +102,7 @@ daemonize_set_user() /* set uid */ if (user_uid != (uid_t)-1 && user_uid != getuid() && setuid(user_uid) == -1) { - throw FmtErrno("Failed to set user \"{}\"", user_name); + throw FmtErrno("Failed to set user {:?}", user_name); } } @@ -201,7 +201,7 @@ daemonize_init(const char *user, const char *group, AllocatedPath &&_pidfile) if (user) { struct passwd *pwd = getpwnam(user); if (pwd == nullptr) - throw FmtRuntimeError("no such user \"{}\"", user); + throw FmtRuntimeError("no such user {:?}", user); user_uid = pwd->pw_uid; user_gid = pwd->pw_gid; @@ -215,7 +215,7 @@ daemonize_init(const char *user, const char *group, AllocatedPath &&_pidfile) if (group) { struct group *grp = getgrnam(group); if (grp == nullptr) - throw FmtRuntimeError("no such group \"{}\"", group); + throw FmtRuntimeError("no such group {:?}", group); user_gid = grp->gr_gid; had_group = true; } diff --git a/src/unix/PidFile.hxx b/src/unix/PidFile.hxx index 69fb13892..b50d42b6c 100644 --- a/src/unix/PidFile.hxx +++ b/src/unix/PidFile.hxx @@ -27,7 +27,7 @@ public: fd = OpenFile(path, O_WRONLY|O_CREAT|O_TRUNC, 0666).Steal(); if (fd < 0) - throw FmtErrno("Failed to create pid file \"{}\"", + throw FmtErrno("Failed to create pid file {:?}", path); } diff --git a/src/zeroconf/Bonjour.cxx b/src/zeroconf/Bonjour.cxx index b8297b107..bb5403d94 100644 --- a/src/zeroconf/Bonjour.cxx +++ b/src/zeroconf/Bonjour.cxx @@ -63,7 +63,7 @@ BonjourHelper::Callback([[maybe_unused]] DNSServiceRef sdRef, helper.Cancel(); } else { FmtDebug(bonjour_domain, - "Registered zeroconf service with name '{}'", + "Registered zeroconf service with name {:?}", name); } } diff --git a/src/zeroconf/avahi/Helper.cxx b/src/zeroconf/avahi/Helper.cxx index a7ed97aec..881c1c4f8 100644 --- a/src/zeroconf/avahi/Helper.cxx +++ b/src/zeroconf/avahi/Helper.cxx @@ -47,7 +47,7 @@ AvahiInit(EventLoop &event_loop, const char *service_name, const char *service_type, unsigned port) { if (!avahi_is_valid_service_name(service_name)) - throw FmtRuntimeError("Invalid zeroconf_name \"{}\"", + throw FmtRuntimeError("Invalid zeroconf_name {:?}", service_name); auto client = shared_avahi_client.lock(); diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx index 68a08c55f..a3e615a48 100644 --- a/test/DumpDatabase.cxx +++ b/test/DumpDatabase.cxx @@ -55,7 +55,7 @@ public: } void OnDatabaseSongRemoved(const char *uri) noexcept override { - fmt::print("SongRemoved '{}'\n", uri); + fmt::print("SongRemoved {:?}\n", uri); } };