Partition, ...: use libfmt for logging

This commit is contained in:
Max Kellermann 2021-06-24 20:22:48 +02:00
parent 0185d58a2b
commit 6f539cfcd6
44 changed files with 320 additions and 296 deletions

View File

@ -269,7 +269,6 @@ sources = [
'src/command/CommandListBuilder.cxx',
'src/Idle.cxx',
'src/IdleFlags.cxx',
'src/decoder/Domain.cxx',
'src/decoder/Thread.cxx',
'src/decoder/Control.cxx',
'src/decoder/Bridge.cxx',

View File

@ -240,16 +240,16 @@ cycle_log_files() noexcept
fd = open_log_file();
if (fd < 0) {
const std::string out_path_utf8 = out_path.ToUTF8();
FormatError(log_domain,
"error re-opening log file: %s",
out_path_utf8.c_str());
FmtError(log_domain,
"error re-opening log file: {}",
out_path_utf8);
return -1;
}
redirect_logs(fd);
close(fd);
FormatDebug(log_domain, "Done cycling log files");
LogDebug(log_domain, "Done cycling log files");
return 0;
#endif
}

View File

@ -287,9 +287,8 @@ initialize_decoder_and_player(Instance &instance,
"positive integer", s);
if (result < MIN_BUFFER_SIZE) {
FormatWarning(config_domain, "buffer size %lu is too small, using %lu bytes instead",
(unsigned long)result,
(unsigned long)MIN_BUFFER_SIZE);
FmtWarning(config_domain, "buffer size {} is too small, using {} bytes instead",
result, MIN_BUFFER_SIZE);
result = MIN_BUFFER_SIZE;
}
@ -521,8 +520,8 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
raw_config.GetUnsigned(ConfigOption::AUTO_UPDATE_DEPTH,
INT_MAX));
#else
FormatWarning(config_domain,
"inotify: auto_update was disabled. enable during compilation phase");
LogWarning(config_domain,
"inotify: auto_update was disabled. enable during compilation phase");
#endif
}
#endif

View File

@ -21,6 +21,7 @@
#include "Partition.hxx"
#include "Instance.hxx"
#include "Log.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "song/DetachedSong.hxx"
#include "mixer/Volume.hxx"
#include "IdleFlags.hxx"
@ -67,13 +68,14 @@ PrefetchSong(InputCacheManager &cache, const char *uri) noexcept
if (cache.Contains(uri))
return;
FormatDebug(cache_domain, "Prefetch '%s'", uri);
FmtDebug(cache_domain, "Prefetch '{}'", uri);
try {
cache.Prefetch(uri);
} catch (...) {
FormatError(std::current_exception(),
"Prefetch '%s' failed", uri);
FmtError(cache_domain,
"Prefetch '{}' failed: {}",
uri, std::current_exception());
}
}

View File

@ -93,8 +93,8 @@ StateFile::Write(OutputStream &os)
void
StateFile::Write()
{
FormatDebug(state_file_domain,
"Saving state file %s", path_utf8.c_str());
FmtDebug(state_file_domain,
"Saving state file {}", path_utf8);
try {
FileOutputStream fos(config.path);
@ -112,7 +112,7 @@ StateFile::Read()
try {
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);
@ -135,9 +135,9 @@ try {
#endif
if (!success)
FormatError(state_file_domain,
"Unrecognized line in state file: %s",
line);
FmtError(state_file_domain,
"Unrecognized line in state file: {}",
line);
}
RememberVersions();

View File

@ -18,12 +18,14 @@
*/
#include "Client.hxx"
#include "Domain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "Log.hxx"
void
Client::OnSocketError(std::exception_ptr ep) noexcept
{
FormatError(ep, "error on client %d", num);
FmtError(client_domain, "error on client {}: {}", num, ep);
SetExpired();
}

View File

@ -76,8 +76,8 @@ client_new(EventLoop &loop, Partition &partition,
client_list.Add(*client);
partition.clients.push_back(*client);
FormatInfo(client_domain, "[%u] opened from %s",
num, remote.c_str());
FmtInfo(client_domain, "[{}] opened from {}",
num, remote);
}
void
@ -89,6 +89,6 @@ Client::Close() noexcept
if (FullyBufferedSocket::IsDefined())
FullyBufferedSocket::Close();
FormatInfo(client_domain, "[%u] closed", num);
FmtInfo(client_domain, "[{}] closed", num);
delete this;
}

View File

@ -39,9 +39,9 @@ Client::ProcessCommandList(bool list_ok,
for (auto &&i : list) {
char *cmd = &*i.begin();
FormatDebug(client_domain, "process command \"%s\"", cmd);
FmtDebug(client_domain, "process command \"{}\"", 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())
return CommandResult::CLOSE;
else if (ret != CommandResult::OK)
@ -62,9 +62,9 @@ Client::ProcessLine(char *line) noexcept
/* all valid MPD commands begin with a lower case
letter; this could be a badly routed HTTP
request */
FormatWarning(client_domain,
"[%u] malformed command \"%s\"",
num, line);
FmtWarning(client_domain,
"[{}] malformed command \"{}\"",
num, line);
return CommandResult::CLOSE;
}
@ -83,9 +83,9 @@ Client::ProcessLine(char *line) noexcept
} else if (idle_waiting) {
/* during idle mode, clients must not send anything
except "noidle" */
FormatWarning(client_domain,
"[%u] command \"%s\" during idle",
num, line);
FmtWarning(client_domain,
"[{}] command \"{}\" during idle",
num, line);
return CommandResult::CLOSE;
}
@ -93,9 +93,9 @@ Client::ProcessLine(char *line) noexcept
if (StringIsEqual(line, CLIENT_LIST_MODE_END)) {
const unsigned id = num;
FormatDebug(client_domain,
"[%u] process command list",
id);
FmtDebug(client_domain,
"[{}] process command list",
id);
const bool ok_mode = cmd_list.IsOKMode();
auto list = cmd_list.Commit();
@ -103,9 +103,9 @@ Client::ProcessLine(char *line) noexcept
auto ret = ProcessCommandList(ok_mode,
std::move(list));
FormatDebug(client_domain,
"[%u] process command "
"list returned %i", id, int(ret));
FmtDebug(client_domain,
"[{}] process command "
"list returned {}", id, unsigned(ret));
if (ret == CommandResult::OK)
command_success(*this);
@ -113,11 +113,10 @@ Client::ProcessLine(char *line) noexcept
return ret;
} else {
if (!cmd_list.Add(line)) {
FormatWarning(client_domain,
"[%u] command list size "
"is larger than the max (%lu)",
num,
(unsigned long)client_max_command_list_size);
FmtWarning(client_domain,
"[{}] command list size "
"is larger than the max ({})",
num, client_max_command_list_size);
return CommandResult::CLOSE;
}
@ -133,13 +132,13 @@ Client::ProcessLine(char *line) noexcept
} else {
const unsigned id = num;
FormatDebug(client_domain,
"[%u] process command \"%s\"",
id, line);
FmtDebug(client_domain,
"[{}] process command \"{}\"",
id, line);
auto ret = command_process(*this, 0, line);
FormatDebug(client_domain,
"[%u] command returned %i",
id, int(ret));
FmtDebug(client_domain,
"[{}] command returned {}",
id, unsigned(ret));
if (IsExpired())
return CommandResult::CLOSE;

View File

@ -33,9 +33,9 @@ Check(const ConfigBlock &block)
for (const auto &i : block.block_params) {
if (!i.used)
FormatWarning(config_domain,
"option '%s' on line %i was not recognized",
i.name.c_str(), i.line);
FmtWarning(config_domain,
"option '{}' on line {} was not recognized",
i.name, i.line);
}
}

View File

@ -116,9 +116,9 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader,
const ConfigTemplate &option = config_block_templates[i];
if (option.deprecated)
FormatWarning(config_file_domain,
"config parameter \"%s\" on line %u is deprecated",
name, reader.GetLineNumber());
FmtWarning(config_file_domain,
"config parameter \"{}\" on line {} is deprecated",
name, reader.GetLineNumber());
if (!option.repeatable)
if (const auto *block = config_data.GetBlock(o))
@ -148,9 +148,9 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
const ConfigTemplate &option = config_param_templates[i];
if (option.deprecated)
FormatWarning(config_file_domain,
"config parameter \"%s\" on line %u is deprecated",
name, reader.GetLineNumber());
FmtWarning(config_file_domain,
"config parameter \"{}\" on line {} is deprecated",
name, reader.GetLineNumber());
if (!option.repeatable)
/* if the option is not repeatable, override the old
@ -238,7 +238,7 @@ ReadConfigFile(ConfigData &config_data, Path path)
assert(!path.IsNull());
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);

View File

@ -23,6 +23,7 @@
#include "db/plugins/simple/Directory.hxx"
#include "db/plugins/simple/Song.hxx"
#include "storage/StorageInterface.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "fs/AllocatedPath.hxx"
#include "storage/FileInfo.hxx"
#include "archive/ArchiveList.hxx"
@ -82,14 +83,14 @@ UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
}
modified = true;
FormatNotice(update_domain, "added %s/%s",
directory.GetPath(), name);
FmtNotice(update_domain, "added {}/{}",
directory.GetPath(), name);
}
} else {
if (!song->UpdateFileInArchive(archive)) {
FormatDebug(update_domain,
"deleting unrecognized file %s/%s",
directory.GetPath(), name);
FmtDebug(update_domain,
"deleting unrecognized file {}/{}",
directory.GetPath(), name);
editor.LockDeleteSong(directory, song);
}
}
@ -107,8 +108,8 @@ class UpdateArchiveVisitor final : public ArchiveVisitor {
:walk(_walk), archive(_archive), directory(_directory) {}
void VisitArchiveEntry(const char *path_utf8) override {
FormatDebug(update_domain,
"adding archive file: %s", path_utf8);
FmtDebug(update_domain,
"adding archive file: {}", path_utf8);
walk.UpdateArchiveTree(archive, directory, path_utf8);
}
};
@ -149,7 +150,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, std::string_view name,
return;
}
FormatDebug(update_domain, "archive %s opened", path_fs.c_str());
FmtDebug(update_domain, "archive {} opened", path_fs);
UpdateArchiveVisitor visitor(*this, *file, *directory);
file->Visit(visitor);

View File

@ -75,9 +75,9 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
// shouldn't be necessary but it's there..
song->mtime = info.mtime;
FormatNotice(update_domain, "added %s/%s",
contdir->GetPath(),
song->filename.c_str());
FmtNotice(update_domain, "added {}/{}",
contdir->GetPath(),
song->filename);
{
const ScopeDatabaseLock protect;

View File

@ -20,9 +20,11 @@
#include "InotifyQueue.hxx"
#include "InotifyDomain.hxx"
#include "Service.hxx"
#include "Log.hxx"
#include "UpdateDomain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "protocol/Ack.hxx" // for class ProtocolError
#include "util/StringCompare.hxx"
#include "Log.hxx"
/**
* Wait this long after the last change before calling
@ -53,14 +55,15 @@ InotifyQueue::OnDelay() noexcept
throw;
}
} catch (...) {
FormatError(std::current_exception(),
"Failed to enqueue '%s'", uri_utf8);
FmtError(update_domain,
"Failed to enqueue '{}': {}",
uri_utf8, std::current_exception());
queue.pop_front();
continue;
}
FormatDebug(inotify_domain, "updating '%s' job=%u",
uri_utf8, id);
FmtDebug(inotify_domain, "updating '{}' job={}",
uri_utf8, id);
queue.pop_front();
}

View File

@ -22,6 +22,8 @@
#include "InotifyQueue.hxx"
#include "InotifyDomain.hxx"
#include "ExcludeList.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "storage/StorageInterface.hxx"
#include "input/InputStream.hxx"
#include "input/Error.hxx"
@ -223,9 +225,9 @@ try {
ret = inotify_source->Add(child_path_fs.c_str(),
IN_MASK);
} catch (...) {
FormatError(std::current_exception(),
"Failed to register %s",
child_path_fs.c_str());
FmtError(inotify_domain,
"Failed to register %s: {}",
child_path_fs, std::current_exception());
continue;
}

View File

@ -22,6 +22,7 @@
#include "db/DatabaseLock.hxx"
#include "db/PlaylistVector.hxx"
#include "db/plugins/simple/Directory.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "song/DetachedSong.hxx"
#include "input/InputStream.hxx"
#include "playlist/PlaylistPlugin.hxx"
@ -49,7 +50,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
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 {
Mutex mutex;
@ -80,8 +81,9 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
}
}
} catch (...) {
FormatError(std::current_exception(),
"Failed to scan playlist '%s'", uri_utf8.c_str());
FmtError(update_domain,
"Failed to scan playlist '{}': {}",
uri_utf8, std::current_exception());
editor.LockDeleteDirectory(directory);
}
}

View File

@ -41,7 +41,7 @@ UpdateRemoveService::RunDeferred() noexcept
}
for (const auto &uri : copy) {
FormatNotice(update_domain, "removing %s", uri.c_str());
FmtNotice(update_domain, "removing {}", uri);
listener.OnDatabaseSongRemoved(uri.c_str());
}

View File

@ -20,6 +20,7 @@
#include "Walk.hxx"
#include "UpdateIO.hxx"
#include "UpdateDomain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "db/DatabaseLock.hxx"
#include "db/plugins/simple/Directory.hxx"
#include "db/plugins/simple/Song.hxx"
@ -41,9 +42,9 @@ try {
}
if (!directory_child_access(storage, directory, name, R_OK)) {
FormatError(update_domain,
"no read permissions on %s/%s",
directory.GetPath(), name);
FmtError(update_domain,
"no read permissions on {}/{}",
directory.GetPath(), name);
if (song != nullptr)
editor.LockDeleteSong(directory, song);
@ -59,14 +60,14 @@ try {
}
if (song == nullptr) {
FormatDebug(update_domain, "reading %s/%s",
directory.GetPath(), name);
FmtDebug(update_domain, "reading {}/{}",
directory.GetPath(), name);
auto new_song = Song::LoadFile(storage, name, directory);
if (!new_song) {
FormatDebug(update_domain,
"ignoring unrecognized file %s/%s",
directory.GetPath(), name);
FmtDebug(update_domain,
"ignoring unrecognized file {}/{}",
directory.GetPath(), name);
return;
}
@ -76,24 +77,24 @@ try {
}
modified = true;
FormatNotice(update_domain, "added %s/%s",
directory.GetPath(), name);
FmtNotice(update_domain, "added {}/{}",
directory.GetPath(), name);
} else if (info.mtime != song->mtime || walk_discard) {
FormatNotice(update_domain, "updating %s/%s",
directory.GetPath(), name);
FmtNotice(update_domain, "updating {}/{}",
directory.GetPath(), name);
if (!song->UpdateFile(storage)) {
FormatDebug(update_domain,
"deleting unrecognized file %s/%s",
directory.GetPath(), name);
FmtDebug(update_domain,
"deleting unrecognized file {}/{}",
directory.GetPath(), name);
editor.LockDeleteSong(directory, song);
}
modified = true;
}
} catch (...) {
FormatError(std::current_exception(),
"error reading file %s/%s",
directory.GetPath(), name);
FmtError(update_domain,
"error reading file {}/{}: {}",
directory.GetPath(), name, std::current_exception());
}
bool

View File

@ -223,8 +223,8 @@ try {
if (!UpdateDirectory(*subdir, exclude_list, info))
editor.LockDeleteDirectory(subdir);
} else {
FormatDebug(update_domain,
"%s is not a directory, archive or music", name);
FmtDebug(update_domain,
"{} is not a directory, archive or music", name);
}
} catch (...) {
LogError(std::current_exception());
@ -520,8 +520,8 @@ UpdateWalk::Walk(Directory &root, const char *path, bool discard) noexcept
return false;
if (!info.IsDirectory()) {
FormatError(update_domain, "Not a directory: %s",
storage.MapUTF8("").c_str());
FmtError(update_domain, "Not a directory: {}",
storage.MapUTF8(""));
return false;
}

View File

@ -20,9 +20,9 @@
#include "config.h"
#include "DecoderList.hxx"
#include "DecoderPlugin.hxx"
#include "Domain.hxx"
#include "decoder/Features.h"
#include "PluginUnavailable.hxx"
#include "Log.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "config/Data.hxx"
#include "config/Block.hxx"
#include "plugins/AudiofileDecoderPlugin.hxx"
@ -49,6 +49,8 @@
#include "plugins/FluidsynthDecoderPlugin.hxx"
#include "plugins/SidplayDecoderPlugin.hxx"
#include "util/RuntimeError.hxx"
#include "Log.hxx"
#include "PluginUnavailable.hxx"
#include <iterator>
@ -160,9 +162,9 @@ decoder_plugin_init_all(const ConfigData &config)
if (plugin.Init(*param))
decoder_plugins_enabled[i] = true;
} catch (const PluginUnavailable &e) {
FormatError(e,
"Decoder plugin '%s' is unavailable",
plugin.name);
FmtError(decoder_domain,
"Decoder plugin '{}' is unavailable: {}",
plugin.name, std::current_exception());
} catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to initialize decoder plugin '%s'",
plugin.name));

View File

@ -3,6 +3,7 @@ decoder_features = configuration_data()
decoder_api = static_library(
'decoder_api',
'DecoderAPI.cxx',
'Domain.cxx',
'Reader.cxx',
'DecoderBuffer.cxx',
'DecoderPlugin.cxx',

View File

@ -357,24 +357,24 @@ faad_stream_decode(DecoderClient &client, InputStream &is,
faad_decoder_decode(decoder, buffer, &frame_info);
if (frame_info.error > 0) {
FormatWarning(faad_decoder_domain,
"error decoding AAC stream: %s",
NeAACDecGetErrorMessage(frame_info.error));
FmtWarning(faad_decoder_domain,
"error decoding AAC stream: {}",
NeAACDecGetErrorMessage(frame_info.error));
break;
}
if (frame_info.channels != audio_format.channels) {
FormatNotice(faad_decoder_domain,
"channel count changed from %u to %u",
audio_format.channels, frame_info.channels);
FmtNotice(faad_decoder_domain,
"channel count changed from {} to {}",
audio_format.channels, frame_info.channels);
break;
}
if (frame_info.samplerate != audio_format.sample_rate) {
FormatNotice(faad_decoder_domain,
"sample rate changed from %u to %lu",
audio_format.sample_rate,
(unsigned long)frame_info.samplerate);
FmtNotice(faad_decoder_domain,
"sample rate changed from {} to {}",
audio_format.sample_rate,
frame_info.samplerate);
break;
}

View File

@ -270,9 +270,9 @@ FfmpegReceiveFrames(DecoderClient &client, InputStream *is,
{
char msg[256];
av_strerror(err, msg, sizeof(msg));
FormatWarning(ffmpeg_domain,
"avcodec_send_packet() failed: %s",
msg);
FmtWarning(ffmpeg_domain,
"avcodec_send_packet() failed: {}",
msg);
}
return DecoderCommand::STOP;
@ -326,8 +326,8 @@ ffmpeg_send_packet(DecoderClient &client, InputStream *is,
{
char msg[256];
av_strerror(err, msg, sizeof(msg));
FormatWarning(ffmpeg_domain,
"avcodec_send_packet() failed: %s", msg);
FmtWarning(ffmpeg_domain,
"avcodec_send_packet() failed: {}", msg);
}
return DecoderCommand::NONE;
@ -355,13 +355,13 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
sample_fmt);
if (name != nullptr)
FormatError(ffmpeg_domain,
"Unsupported libavcodec SampleFormat value: %s (%d)",
name, sample_fmt);
FmtError(ffmpeg_domain,
"Unsupported libavcodec SampleFormat value: {} ({})",
name, sample_fmt);
else
FormatError(ffmpeg_domain,
"Unsupported libavcodec SampleFormat value: %d",
sample_fmt);
FmtError(ffmpeg_domain,
"Unsupported libavcodec SampleFormat value: {}",
sample_fmt);
return SampleFormat::UNDEFINED;
}
@ -499,8 +499,8 @@ FfmpegDecode(DecoderClient &client, InputStream *input,
const AVCodecDescriptor *codec_descriptor =
avcodec_descriptor_get(codec_params.codec_id);
if (codec_descriptor != nullptr)
FormatDebug(ffmpeg_domain, "codec '%s'",
codec_descriptor->name);
FmtDebug(ffmpeg_domain, "codec '{}'",
codec_descriptor->name);
AVCodec *codec = avcodec_find_decoder(codec_params.codec_id);
@ -602,8 +602,8 @@ ffmpeg_decode(DecoderClient &client, InputStream &input)
FfmpegOpenInput(stream.io, input.GetURI(), nullptr);
const auto *input_format = format_context->iformat;
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)",
input_format->name, input_format->long_name);
FmtDebug(ffmpeg_domain, "detected input format '{}' ({})",
input_format->name, input_format->long_name);
FfmpegDecode(client, &input, *format_context);
}
@ -668,8 +668,8 @@ ffmpeg_uri_decode(DecoderClient &client, const char *uri)
FfmpegOpenInput(nullptr, uri, nullptr);
const auto *input_format = format_context->iformat;
FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)",
input_format->name, input_format->long_name);
FmtDebug(ffmpeg_domain, "detected input format '{}' ({})",
input_format->name, input_format->long_name);
FfmpegDecode(client, nullptr, *format_context);
}

View File

@ -20,6 +20,7 @@
#include "config.h"
#include "MikmodDecoderPlugin.hxx"
#include "../DecoderAPI.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "tag/Handler.hxx"
#include "fs/Path.hxx"
#include "util/Domain.hxx"
@ -126,9 +127,9 @@ mikmod_decoder_init(const ConfigBlock &block)
DMODE_16BITS);
if (MikMod_Init(params)) {
FormatError(mikmod_domain,
"Could not init MikMod: %s",
MikMod_strerror(MikMod_errno));
FmtError(mikmod_domain,
"Could not init MikMod: {}",
MikMod_strerror(MikMod_errno));
return false;
}
@ -155,8 +156,7 @@ mikmod_decoder_file_decode(DecoderClient &client, Path path_fs)
handle = Player_Load(path2, 128, 0);
if (handle == nullptr) {
FormatError(mikmod_domain,
"failed to open mod: %s", path_fs.c_str());
FmtError(mikmod_domain, "failed to open mod: {}", path_fs);
return;
}
@ -189,8 +189,7 @@ mikmod_decoder_scan_file(Path path_fs, TagHandler &handler) noexcept
MODULE *handle = Player_Load(path2, 128, 0);
if (handle == nullptr) {
FormatDebug(mikmod_domain,
"Failed to open file: %s", path_fs.c_str());
FmtDebug(mikmod_domain, "Failed to open file: {}", path_fs);
return false;
}

View File

@ -65,9 +65,9 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
{
int error = mpg123_open(handle, path_fs);
if (error != MPG123_OK) {
FormatWarning(mpg123_domain,
"libmpg123 failed to open %s: %s",
path_fs, mpg123_plain_strerror(error));
FmtWarning(mpg123_domain,
"libmpg123 failed to open {}: {}",
path_fs, mpg123_plain_strerror(error));
return false;
}
@ -77,17 +77,17 @@ mpd_mpg123_open(mpg123_handle *handle, const char *path_fs,
int channels, encoding;
error = mpg123_getformat(handle, &rate, &channels, &encoding);
if (error != MPG123_OK) {
FormatWarning(mpg123_domain,
"mpg123_getformat() failed: %s",
mpg123_plain_strerror(error));
FmtWarning(mpg123_domain,
"mpg123_getformat() failed: {}",
mpg123_plain_strerror(error));
return false;
}
if (encoding != MPG123_ENC_SIGNED_16) {
/* other formats not yet implemented */
FormatWarning(mpg123_domain,
"expected MPG123_ENC_SIGNED_16, got %d",
encoding);
FmtWarning(mpg123_domain,
"expected MPG123_ENC_SIGNED_16, got {}",
encoding);
return false;
}
@ -187,9 +187,9 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
int error;
mpg123_handle *const handle = mpg123_new(nullptr, &error);
if (handle == nullptr) {
FormatError(mpg123_domain,
"mpg123_new() failed: %s",
mpg123_plain_strerror(error));
FmtError(mpg123_domain,
"mpg123_new() failed: {}",
mpg123_plain_strerror(error));
return;
}
@ -238,9 +238,9 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
error = mpg123_read(handle, buffer, sizeof(buffer), &nbytes);
if (error != MPG123_OK) {
if (error != MPG123_DONE)
FormatWarning(mpg123_domain,
"mpg123_read() failed: %s",
mpg123_plain_strerror(error));
FmtWarning(mpg123_domain,
"mpg123_read() failed: {}",
mpg123_plain_strerror(error));
break;
}
@ -277,9 +277,9 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept
int error;
mpg123_handle *const handle = mpg123_new(nullptr, &error);
if (handle == nullptr) {
FormatError(mpg123_domain,
"mpg123_new() failed: %s",
mpg123_plain_strerror(error));
FmtError(mpg123_domain,
"mpg123_new() failed: {}",
mpg123_plain_strerror(error));
return false;
}

View File

@ -19,6 +19,7 @@
#include "config.h"
#include "ServerSocket.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "net/IPv4Address.hxx"
#include "net/IPv6Address.hxx"
#include "net/StaticSocketAddress.hxx"
@ -150,16 +151,16 @@ ServerSocket::OneServerSocket::Accept() noexcept
UniqueSocketDescriptor peer_fd(event.GetSocket().AcceptNonBlock(peer_address));
if (!peer_fd.IsDefined()) {
const SocketErrorMessage msg;
FormatError(server_socket_domain,
"accept() failed: %s", (const char *)msg);
FmtError(server_socket_domain,
"accept() failed: {}", (const char *)msg);
return;
}
if (!peer_fd.SetKeepAlive()) {
const SocketErrorMessage msg;
FormatError(server_socket_domain,
"Could not set TCP keepalive option: %s",
(const char *)msg);
FmtError(server_socket_domain,
"Could not set TCP keepalive option: {}",
(const char *)msg);
}
const auto uid = get_remote_uid(peer_fd.Get());
@ -227,12 +228,13 @@ ServerSocket::Open()
if (good != nullptr && good->GetSerial() == i.GetSerial()) {
const auto address_string = i.ToString();
const auto good_string = good->ToString();
FormatError(std::current_exception(),
"bind to '%s' failed "
"(continuing anyway, because "
"binding to '%s' succeeded)",
address_string.c_str(),
good_string.c_str());
FmtError(server_socket_domain,
"bind to '{}' failed "
"(continuing anyway, because "
"binding to '{}' succeeded): {}",
address_string,
good_string,
std::current_exception());
} else if (bad == nullptr) {
bad = &i;

View File

@ -48,8 +48,8 @@ SetFSCharset(const char *charset)
fs_converter = IcuConverter::Create(charset);
assert(fs_converter != nullptr);
FormatDebug(path_domain,
"SetFSCharset: fs charset is: %s", fs_charset.c_str());
FmtDebug(path_domain,
"SetFSCharset: fs charset is {}", fs_charset);
}
#endif

View File

@ -19,6 +19,7 @@
#include "CheckFile.hxx"
#include "Log.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "config/Domain.hxx"
#include "FileInfo.hxx"
#include "Path.hxx"
@ -31,8 +32,7 @@ CheckDirectoryReadable(Path path_fs)
try {
const FileInfo fi(path_fs);
if (!fi.IsDirectory()) {
FormatError(config_domain,
"Not a directory: %s", path_fs.ToUTF8().c_str());
FmtError(config_domain, "Not a directory: {}", path_fs);
return;
}
@ -42,9 +42,9 @@ try {
const FileInfo fi2(x);
} catch (const std::system_error &e) {
if (IsAccessDenied(e))
FormatError(config_domain,
"No permission to traverse (\"execute\") directory: %s",
path_fs.ToUTF8().c_str());
FmtError(config_domain,
"No permission to traverse (\"execute\") directory: {}",
path_fs);
}
#endif
@ -52,9 +52,9 @@ try {
const DirectoryReader reader(path_fs);
} catch (const std::system_error &e) {
if (IsAccessDenied(e))
FormatError(config_domain,
"No permission to read directory: %s",
path_fs.ToUTF8().c_str());
FmtError(config_domain,
"No permission to read directory: {}",
path_fs);
}
} catch (...) {
LogError(std::current_exception());

View File

@ -207,7 +207,8 @@ input_cdio_open(const char *uri,
cdio_cddap_verbose_set(drv, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
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);
}
@ -301,8 +302,8 @@ CdioParanoiaInputStream::Read(std::unique_lock<Mutex> &,
} catch (...) {
char *s_err = cdio_cddap_errors(drv);
if (s_err) {
FormatError(cdio_domain,
"paranoia_read: %s", s_err);
FmtError(cdio_domain,
"paranoia_read: {}", s_err);
cdio_cddap_free_messages(s_err);
}

View File

@ -27,10 +27,10 @@
#include "input/ProxyInputStream.hxx"
#include "input/FailingInputStream.hxx"
#include "input/InputPlugin.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "config/Block.hxx"
#include "thread/Mutex.hxx"
#include "util/Domain.hxx"
#include "util/Exception.hxx"
#include "util/StringCompare.hxx"
#include "Log.hxx"
@ -117,8 +117,8 @@ TidalInputStream::OnTidalSession() noexcept
void
TidalInputStream::OnTidalTrackSuccess(std::string url) noexcept
{
FormatDebug(tidal_domain, "Tidal track '%s' resolves to %s",
track_id.c_str(), url.c_str());
FmtDebug(tidal_domain, "Tidal track '{}' resolves to {}",
track_id, url);
const std::lock_guard<Mutex> protect(mutex);
@ -154,8 +154,8 @@ TidalInputStream::OnTidalTrackError(std::exception_ptr e) noexcept
/* the session has expired - obtain a new session id
by logging in again */
FormatInfo(tidal_domain, "Session expired ('%s'), retrying to log in",
GetFullMessage(e).c_str());
FmtInfo(tidal_domain,
"Session expired ('{}'), retrying to log in", e);
retry_login = false;
tidal_session->AddLoginHandler(*this);

View File

@ -38,5 +38,5 @@ LogFfmpegError(int errnum, const char *prefix)
{
char msg[256];
av_strerror(errnum, msg, sizeof(msg));
FormatError(ffmpeg_domain, "%s: %s", prefix, msg);
FmtError(ffmpeg_domain, "{}: {}", prefix, msg);
}

View File

@ -28,5 +28,5 @@ void
LogPulseError(pa_context *context, const char *prefix) noexcept
{
const int e = pa_context_errno(context);
FormatError(pulse_domain, "%s: %s", prefix, pa_strerror(e));
FmtError(pulse_domain, "{}: {}", prefix, pa_strerror(e));
}

View File

@ -106,8 +106,8 @@ read_sw_volume_state(const char *line, MultipleOutputs &outputs)
if (*end == 0 && sv >= 0 && sv <= 100)
software_volume_change(outputs, sv);
else
FormatWarning(volume_domain,
"Can't parse software volume: %s", line);
FmtWarning(volume_domain,
"Can't parse software volume: {}", line);
return true;
}

View File

@ -125,9 +125,9 @@ AlsaMixerMonitor::DispatchSockets() noexcept
int err = snd_mixer_handle_events(mixer);
if (err < 0) {
FormatError(alsa_mixer_domain,
"snd_mixer_handle_events() failed: %s",
snd_strerror(err));
FmtError(alsa_mixer_domain,
"snd_mixer_handle_events() failed: {}",
snd_strerror(err));
if (err == -ENODEV) {
/* the sound device was unplugged; disable

View File

@ -20,6 +20,8 @@
#include "Control.hxx"
#include "Filtered.hxx"
#include "Client.hxx"
#include "Domain.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "mixer/MixerControl.hxx"
#include "config/Block.hxx"
#include "Log.hxx"
@ -286,9 +288,9 @@ AudioOutputControl::Open(std::unique_lock<Mutex> &lock,
try {
mixer_open(output->mixer);
} catch (...) {
FormatError(std::current_exception(),
"Failed to open mixer for '%s'",
GetName());
FmtError(output_domain,
"Failed to open mixer for '{}': {}",
GetName(), std::current_exception());
}
}

View File

@ -20,12 +20,14 @@
#include "Filtered.hxx"
#include "Interface.hxx"
#include "Domain.hxx"
#include "Log.hxx"
#include "lib/fmt/AudioFormatFormatter.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "mixer/MixerInternal.hxx"
#include "mixer/plugins/SoftwareMixerPlugin.hxx"
#include "filter/plugins/ConvertFilterPlugin.hxx"
#include "util/RuntimeError.hxx"
#include "util/StringBuffer.hxx"
#include "Log.hxx"
bool
FilteredAudioOutput::SupportsEnableDisable() const noexcept
@ -91,10 +93,9 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
GetLogName()));
}
FormatDebug(output_domain,
"opened %s audio_format=%s",
GetLogName(),
ToString(out_audio_format).c_str());
FmtDebug(output_domain,
"opened {} audio_format={}",
GetLogName(), out_audio_format);
try {
ConfigureConvertFilter();
@ -109,7 +110,7 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
DSD and fall back to PCM */
LogError(std::current_exception());
FormatError(output_domain, "Retrying without DSD");
LogError(output_domain, "Retrying without DSD");
desired_audio_format.format = SampleFormat::FLOAT;
OpenOutputAndConvert(desired_audio_format);
@ -127,8 +128,9 @@ FilteredAudioOutput::CloseOutput(bool drain) noexcept
try {
Drain();
} catch (...) {
FormatError(std::current_exception(),
"Failed to drain %s", GetLogName());
FmtError(output_domain,
"Failed to drain {}: {}",
GetLogName(), std::current_exception());
}
} else
Cancel();
@ -156,7 +158,7 @@ FilteredAudioOutput::Close(bool drain) noexcept
CloseOutput(drain);
CloseSoftwareMixer();
FormatDebug(output_domain, "closed %s", GetLogName());
FmtDebug(output_domain, "closed {}", GetLogName());
}
std::chrono::steady_clock::duration

View File

@ -22,6 +22,7 @@
#include "Domain.hxx"
#include "OutputAPI.hxx"
#include "Defaults.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "pcm/AudioParser.hxx"
#include "mixer/MixerList.hxx"
#include "mixer/MixerType.hxx"
@ -68,9 +69,9 @@ audio_output_detect()
if (plugin->test_default_device == nullptr)
continue;
FormatInfo(output_domain,
"Attempting to detect a %s audio device",
plugin->name);
FmtInfo(output_domain,
"Attempting to detect a {} audio device",
plugin->name);
if (ao_plugin_test_default_device(plugin))
return plugin;
}
@ -188,9 +189,9 @@ FilteredAudioOutput::Configure(const ConfigBlock &block,
/* It's not really fatal - Part of the filter chain
has been set up already and even an empty one will
work (if only with unexpected behaviour) */
FormatError(std::current_exception(),
"Failed to initialize filter chain for '%s'",
name);
FmtError(output_domain,
"Failed to initialize filter chain for '{}': {}",
name, std::current_exception());
}
}
@ -238,9 +239,9 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
*prepared_filter,
mixer_listener);
} catch (...) {
FormatError(std::current_exception(),
"Failed to initialize hardware mixer for '%s'",
name);
FmtError(output_domain,
"Failed to initialize hardware mixer for '{}': {}",
name, std::current_exception());
}
/* use the hardware mixer for replay gain? */
@ -250,8 +251,8 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
replay_gain_filter_set_mixer(*prepared_replay_gain_filter,
mixer, 100);
else
FormatError(output_domain,
"No such mixer for output '%s'", name);
FmtError(output_domain,
"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");
@ -289,9 +290,9 @@ audio_output_new(EventLoop &normal_event_loop, EventLoop &rt_event_loop,
plugin = audio_output_detect();
FormatNotice(output_domain,
"Successfully detected a %s audio device",
plugin->name);
FmtNotice(output_domain,
"Successfully detected a {} audio device",
plugin->name);
}
/* use the real-time I/O thread only for the ALSA plugin;

View File

@ -22,6 +22,8 @@
#include "Filtered.hxx"
#include "Client.hxx"
#include "Domain.hxx"
#include "lib/fmt/AudioFormatFormatter.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "thread/Util.hxx"
#include "thread/Slack.hxx"
#include "thread/Name.hxx"
@ -166,10 +168,8 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
}
if (f != in_audio_format || f != output->out_audio_format)
FormatDebug(output_domain, "converting in=%s -> f=%s -> out=%s",
ToString(in_audio_format).c_str(),
ToString(f).c_str(),
ToString(output->out_audio_format).c_str());
FmtDebug(output_domain, "converting in={} -> f={} -> out={}",
in_audio_format, f, output->out_audio_format);
}
inline void
@ -231,8 +231,9 @@ AudioOutputControl::FillSourceOrClose() noexcept
try {
return source.Fill(mutex);
} catch (...) {
FormatError(std::current_exception(),
"Failed to filter for %s", GetLogName());
FmtError(output_domain,
"Failed to filter for {}: {}",
GetLogName(), std::current_exception());
InternalCloseError(std::current_exception());
return false;
}
@ -250,9 +251,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept
caught_interrupted = true;
return false;
} catch (...) {
FormatError(std::current_exception(),
"Failed to send tag to %s",
GetLogName());
FmtError(output_domain,
"Failed to send tag to {}: {}",
GetLogName(), std::current_exception());
}
}
@ -277,8 +278,9 @@ AudioOutputControl::PlayChunk(std::unique_lock<Mutex> &lock) noexcept
caught_interrupted = true;
return false;
} catch (...) {
FormatError(std::current_exception(),
"Failed to play on %s", GetLogName());
FmtError(output_domain,
"Failed to play on {}",
GetLogName(), std::current_exception());
InternalCloseError(std::current_exception());
return false;
}
@ -356,9 +358,9 @@ AudioOutputControl::InternalPause(std::unique_lock<Mutex> &lock) noexcept
success = output->IteratePause();
} catch (AudioOutputInterrupted) {
} catch (...) {
FormatError(std::current_exception(),
"Failed to pause %s",
GetLogName());
FmtError(output_domain,
"Failed to pause {}: {}",
GetLogName(), std::current_exception());
}
if (!success) {
@ -416,8 +418,9 @@ AudioOutputControl::InternalDrain() noexcept
output->Drain();
} catch (...) {
FormatError(std::current_exception(),
"Failed to flush filter on %s", GetLogName());
FmtError(output_domain,
"Failed to flush filter on {}: {}",
GetLogName(), std::current_exception());
InternalCloseError(std::current_exception());
return;
}

View File

@ -498,9 +498,9 @@ alsa_test_default_device()
int ret = snd_pcm_open(&handle, default_device,
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if (ret) {
FormatError(alsa_output_domain,
"Error opening default ALSA device: %s",
snd_strerror(-ret));
FmtError(alsa_output_domain,
"Error opening default ALSA device: {}",
snd_strerror(-ret));
return false;
} else
snd_pcm_close(handle);
@ -548,13 +548,13 @@ AlsaOutput::Setup(AudioFormat &audio_format,
buffer_time, period_time,
audio_format, params);
FormatDebug(alsa_output_domain, "format=%s (%s)",
snd_pcm_format_name(hw_result.format),
snd_pcm_format_description(hw_result.format));
FmtDebug(alsa_output_domain, "format={} ({})",
snd_pcm_format_name(hw_result.format),
snd_pcm_format_description(hw_result.format));
FormatDebug(alsa_output_domain, "buffer_size=%u period_size=%u",
(unsigned)hw_result.buffer_size,
(unsigned)hw_result.period_size);
FmtDebug(alsa_output_domain, "buffer_size={} period_size={}",
hw_result.buffer_size,
hw_result.period_size);
AlsaSetupSw(pcm, hw_result.buffer_size - hw_result.period_size,
hw_result.period_size);
@ -708,9 +708,9 @@ AlsaOutput::Open(AudioFormat &audio_format)
throw FormatRuntimeError("Failed to open ALSA device \"%s\": %s",
GetDevice(), snd_strerror(err));
FormatDebug(alsa_output_domain, "opened %s type=%s",
snd_pcm_name(pcm),
snd_pcm_type_name(snd_pcm_type(pcm)));
FmtDebug(alsa_output_domain, "opened {} type={}",
snd_pcm_name(pcm),
snd_pcm_type_name(snd_pcm_type(pcm)));
PcmExport::Params params;
params.alsa_channel_order = true;
@ -734,7 +734,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
#ifdef ENABLE_DSD
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
pcm_export->Open(audio_format.format,
@ -775,13 +775,13 @@ inline int
AlsaOutput::Recover(int err) noexcept
{
if (err == -EPIPE) {
FormatDebug(alsa_output_domain,
"Underrun on ALSA device \"%s\"",
GetDevice());
FmtDebug(alsa_output_domain,
"Underrun on ALSA device \"{}\"",
GetDevice());
} else if (err == -ESTRPIPE) {
FormatDebug(alsa_output_domain,
"ALSA device \"%s\" was suspended",
GetDevice());
FmtDebug(alsa_output_domain,
"ALSA device \"{}\" was suspended",
GetDevice());
}
switch (snd_pcm_state(pcm)) {
@ -1158,7 +1158,7 @@ try {
}
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
data yet, to avoid ALSA xrun */

View File

@ -60,8 +60,8 @@ sndio_test_default_device()
{
auto *hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
if (!hdl) {
FormatError(sndio_output_domain,
"Error opening default sndio device");
LogError(sndio_output_domain,
"Error opening default sndio device");
return false;
}

View File

@ -391,12 +391,12 @@ SlesOutput::Cancel() noexcept
SLresult result = play.SetPlayState(SL_PLAYSTATE_PAUSED);
if (result != SL_RESULT_SUCCESS)
FormatError(sles_domain, "Play.SetPlayState(PAUSED) failed");
LogError(sles_domain, "Play.SetPlayState(PAUSED) failed");
result = queue.Clear();
if (result != SL_RESULT_SUCCESS)
FormatWarning(sles_domain,
"AndroidSimpleBufferQueue.Clear() failed");
LogWarning(sles_domain,
"AndroidSimpleBufferQueue.Clear() failed");
const std::lock_guard<Mutex> protect(mutex);
n_queued = 0;

View File

@ -422,7 +422,7 @@ inline void
WasapiOutputThread::Work() noexcept
try {
SetThreadName("Wasapi Output Worker");
FormatDebug(wasapi_output_domain, "Working thread started");
LogDebug(wasapi_output_domain, "Working thread started");
COM com;
AtScopeExit(this) {
@ -448,8 +448,8 @@ try {
Status current_state = status.load();
switch (current_state) {
case Status::FINISH:
FormatDebug(wasapi_output_domain,
"Working thread stopped");
LogDebug(wasapi_output_domain,
"Working thread stopped");
return;
case Status::PAUSE:
@ -589,8 +589,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
if (device_format.Format.wBitsPerSample == 24) {
params.pack24 = true;
}
FormatDebug(wasapi_output_domain, "Packing data: shift8=%d pack24=%d",
int(params.shift8), int(params.pack24));
FmtDebug(wasapi_output_domain, "Packing data: shift8={} pack24={}",
params.shift8, params.pack24);
pcm_export.emplace();
pcm_export->Open(audio_format.format, audio_format.channels, params);
}
@ -608,11 +608,11 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
FAILED(result)) {
throw MakeHResultError(result, "Unable to get device period");
}
FormatDebug(wasapi_output_domain,
"Default device period: %lu ns, Minimum device period: "
"%lu ns",
(unsigned long)ns(hundred_ns(default_device_period)).count(),
(unsigned long)ns(hundred_ns(min_device_period)).count());
FmtDebug(wasapi_output_domain,
"Default device period: {} ns, Minimum device period: "
"{} ns",
ns(hundred_ns(default_device_period)).count(),
ns(hundred_ns(min_device_period)).count());
REFERENCE_TIME buffer_duration;
if (Exclusive()) {
@ -621,8 +621,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
const REFERENCE_TIME align = hundred_ns(ms(50)).count();
buffer_duration = (align / default_device_period) * default_device_period;
}
FormatDebug(wasapi_output_domain, "Buffer duration: %lu ns",
(unsigned long)ns(hundred_ns(buffer_duration)).count());
FmtDebug(wasapi_output_domain, "Buffer duration: {} ns",
ns(hundred_ns(buffer_duration)).count());
if (Exclusive()) {
if (HRESULT result = client->Initialize(
@ -639,10 +639,9 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
std::ceil(double(buffer_size_in_frames *
hundred_ns(s(1)).count()) /
SampleRate());
FormatDebug(
wasapi_output_domain,
"Aligned buffer duration: %lu ns",
(unsigned long)ns(hundred_ns(buffer_duration)).count());
FmtDebug(wasapi_output_domain,
"Aligned buffer duration: {} ns",
ns(hundred_ns(buffer_duration)).count());
client.reset();
client = Activate<IAudioClient>(*device);
result = client->Initialize(
@ -687,8 +686,7 @@ WasapiOutput::Close() noexcept
try {
thread->CheckException();
} catch (...) {
FormatError(std::current_exception(),
"exception while stopping");
LogError(wasapi_output_domain, "exception while stopping");
}
thread->Finish();
com_worker->Async([&]() {
@ -1029,8 +1027,8 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator)
if (name == nullptr)
continue;
FormatNotice(wasapi_output_domain,
"Device \"%u\" \"%s\"", i, name.c_str());
FmtNotice(wasapi_output_domain,
"Device \"{}\" \"{}\"", i, name);
}
}

View File

@ -558,10 +558,10 @@ Player::CheckDecoderStartup(std::unique_lock<Mutex> &lock) noexcept
}
if (!paused && !OpenOutput()) {
FormatError(player_domain,
"problems opening audio device "
"while playing \"%s\"",
dc.song->GetURI());
FmtError(player_domain,
"problems opening audio device "
"while playing \"{}\"",
dc.song->GetURI());
return true;
}
@ -964,7 +964,7 @@ Player::SongBorder() noexcept
{
const ScopeUnlock unlock(pc.mutex);
FormatNotice(player_domain, "played \"%s\"", song->GetURI());
FmtNotice(player_domain, "played \"{}\"", song->GetURI());
ReplacePipe(dc.pipe);
@ -1135,7 +1135,7 @@ Player::Run() noexcept
cross_fade_tag.reset();
if (song != nullptr) {
FormatNotice(player_domain, "played \"%s\"", song->GetURI());
FmtNotice(player_domain, "played \"{}\"", song->GetURI());
song.reset();
}

View File

@ -23,6 +23,7 @@
*/
#include "StorageState.hxx"
#include "lib/fmt/ExceptionFormatter.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "storage/Registry.hxx"
@ -90,7 +91,9 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
else if ((value = StringAfterPrefix(line, MOUNT_STATE_STORAGE_URI)))
uri = value;
else
FormatError(storage_domain, "Unrecognized line in mountpoint state: %s", line);
FmtError(storage_domain,
"Unrecognized line in mountpoint state: {}",
line);
}
if (instance.storage == nullptr)
@ -104,7 +107,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
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;
if (composite_storage.IsMountPoint(uri.c_str())) {
@ -120,7 +123,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
auto &event_loop = instance.io_thread.GetEventLoop();
auto storage = CreateStorageURI(event_loop, url.c_str());
if (storage == nullptr) {
FormatError(storage_domain, "Unrecognized storage URI: %s", url.c_str());
FmtError(storage_domain, "Unrecognized storage URI: {}", url);
return true;
}
@ -128,9 +131,9 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
try {
db->Mount(uri.c_str(), url.c_str());
} catch (...) {
FormatError(std::current_exception(),
"Failed to restore mount to %s",
url.c_str());
FmtError(storage_domain,
"Failed to restore mount to {}: {}",
url, std::current_exception());
return true;
}
}

View File

@ -83,7 +83,7 @@ FatalSystemError(const char *msg)
FatalSystemError(msg, GetLastError());
#else
auto system_error = std::strerror(errno);
FormatError(fatal_error_domain, "%s: %s", msg, system_error);
FmtError(fatal_error_domain, "{}: {}", msg, system_error);
Abort();
#endif
}