From c843bce9f5f4d7e56c89e343eabc37d554701a5e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 23 Sep 2020 12:54:15 +0200 Subject: [PATCH] LogLevel: rename DEFAULT to NOTICE "DEFAULT" is a bad name - all it says is that it's the default value, but it doesn't say what it means. The name NOTICE mimics the syslog level. --- doc/mpd.conf.5.rst | 4 ++-- doc/mpdconf.example | 2 +- src/Log.cxx | 4 ++-- src/Log.hxx | 6 +++--- src/LogBackend.cxx | 6 +++--- src/LogInit.cxx | 8 +++++--- src/LogLevel.hxx | 2 +- src/Main.cxx | 12 ++++++------ src/db/update/Archive.cxx | 4 ++-- src/db/update/Container.cxx | 6 +++--- src/db/update/Remove.cxx | 2 +- src/db/update/UpdateSong.cxx | 8 ++++---- src/decoder/plugins/FaadDecoderPlugin.cxx | 14 +++++++------- src/output/Init.cxx | 14 +++++++------- src/output/plugins/JackOutputPlugin.cxx | 2 +- src/output/plugins/WasapiOutputPlugin.cxx | 4 ++-- src/player/Thread.cxx | 4 ++-- src/zeroconf/ZeroconfAvahi.cxx | 16 ++++++++-------- 18 files changed, 60 insertions(+), 58 deletions(-) diff --git a/doc/mpd.conf.5.rst b/doc/mpd.conf.5.rst index a542569b2..37464fc18 100644 --- a/doc/mpd.conf.5.rst +++ b/doc/mpd.conf.5.rst @@ -83,12 +83,12 @@ log_level - :samp:`error`: errors - :samp:`warning`: warnings - - :samp:`default`: interesting informational messages + - :samp:`notice`: interesting informational messages - :samp:`info`: unimportant informational messages - :samp:`verbose`: debug messages (for developers and for troubleshooting) - The default is :samp:`default`. + The default is :samp:`notice`. follow_outside_symlinks Control if MPD will follow symbolic links pointing outside the music dir. You diff --git a/doc/mpdconf.example b/doc/mpdconf.example index 01326fa9d..ec1f9ffaa 100644 --- a/doc/mpdconf.example +++ b/doc/mpdconf.example @@ -92,7 +92,7 @@ # Suppress all messages below the given threshold. Use "verbose" for # troubleshooting. # -#log_level "default" +#log_level "notice" # # Setting "restore_paused" to "yes" puts MPD into pause mode instead # of starting playback after startup. diff --git a/src/Log.cxx b/src/Log.cxx index 21fcdefb8..277e80d72 100644 --- a/src/Log.cxx +++ b/src/Log.cxx @@ -65,11 +65,11 @@ FormatInfo(const Domain &domain, const char *fmt, ...) noexcept } void -FormatDefault(const Domain &domain, const char *fmt, ...) noexcept +FormatNotice(const Domain &domain, const char *fmt, ...) noexcept { std::va_list ap; va_start(ap, fmt); - LogFormatV(LogLevel::DEFAULT, domain, fmt, ap); + LogFormatV(LogLevel::NOTICE, domain, fmt, ap); va_end(ap); } diff --git a/src/Log.hxx b/src/Log.hxx index eb805368a..672b924ed 100644 --- a/src/Log.hxx +++ b/src/Log.hxx @@ -77,14 +77,14 @@ void FormatInfo(const Domain &domain, const char *fmt, ...) noexcept; static inline void -LogDefault(const Domain &domain, const char *msg) noexcept +LogNotice(const Domain &domain, const char *msg) noexcept { - Log(LogLevel::DEFAULT, domain, msg); + Log(LogLevel::NOTICE, domain, msg); } gcc_printf(2,3) void -FormatDefault(const Domain &domain, const char *fmt, ...) noexcept; +FormatNotice(const Domain &domain, const char *fmt, ...) noexcept; static inline void LogWarning(const Domain &domain, const char *msg) noexcept diff --git a/src/LogBackend.cxx b/src/LogBackend.cxx index f6395a54f..71389b7fc 100644 --- a/src/LogBackend.cxx +++ b/src/LogBackend.cxx @@ -47,7 +47,7 @@ ToAndroidLogLevel(LogLevel log_level) noexcept return ANDROID_LOG_DEBUG; case LogLevel::INFO: - case LogLevel::DEFAULT: + case LogLevel::NOTICE: return ANDROID_LOG_INFO; case LogLevel::WARNING: @@ -63,7 +63,7 @@ ToAndroidLogLevel(LogLevel log_level) noexcept #else -static LogLevel log_threshold = LogLevel::DEFAULT; +static LogLevel log_threshold = LogLevel::NOTICE; static bool enable_timestamp; @@ -122,7 +122,7 @@ ToSysLogLevel(LogLevel log_level) noexcept case LogLevel::INFO: return LOG_INFO; - case LogLevel::DEFAULT: + case LogLevel::NOTICE: return LOG_NOTICE; case LogLevel::WARNING: diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 3fcbdcfda..680d27867 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -95,8 +95,10 @@ log_init_file(int line) static inline LogLevel parse_log_level(const char *value) { - if (StringIsEqual(value, "default")) - return LogLevel::DEFAULT; + if (StringIsEqual(value, "notice") || + /* deprecated name: */ + StringIsEqual(value, "default")) + return LogLevel::NOTICE; else if (StringIsEqual(value, "info") || /* deprecated since MPD 0.22: */ StringIsEqual(value, "secure")) @@ -141,7 +143,7 @@ log_init(const ConfigData &config, bool verbose, bool use_stdout) SetLogThreshold(config.With(ConfigOption::LOG_LEVEL, [](const char *s){ return s != nullptr ? parse_log_level(s) - : LogLevel::DEFAULT; + : LogLevel::NOTICE; })); if (use_stdout) { diff --git a/src/LogLevel.hxx b/src/LogLevel.hxx index 0ce13e1cf..a199d19aa 100644 --- a/src/LogLevel.hxx +++ b/src/LogLevel.hxx @@ -42,7 +42,7 @@ enum class LogLevel { /** * Interesting informational message. */ - DEFAULT, + NOTICE, /** * Warning: something may be wrong. diff --git a/src/Main.cxx b/src/Main.cxx index bcba497ba..5cf7037e7 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -194,16 +194,16 @@ glue_db_init_and_load(Instance &instance, const ConfigData &config) config); if (instance.storage == nullptr) { - LogDefault(config_domain, - "Found database setting without " - "music_directory - disabling database"); + LogNotice(config_domain, + "Found database setting without " + "music_directory - disabling database"); return true; } } else { if (IsStorageConfigured(config)) - LogDefault(config_domain, - "Ignoring the storage configuration " - "because the database does not need it"); + LogNotice(config_domain, + "Ignoring the storage configuration " + "because the database does not need it"); } try { diff --git a/src/db/update/Archive.cxx b/src/db/update/Archive.cxx index 53bb8660d..9b9531ec4 100644 --- a/src/db/update/Archive.cxx +++ b/src/db/update/Archive.cxx @@ -82,8 +82,8 @@ UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory, } modified = true; - FormatDefault(update_domain, "added %s/%s", - directory.GetPath(), name); + FormatNotice(update_domain, "added %s/%s", + directory.GetPath(), name); } } else { if (!song->UpdateFileInArchive(archive)) { diff --git a/src/db/update/Container.cxx b/src/db/update/Container.cxx index 2dd1571cd..410ddee62 100644 --- a/src/db/update/Container.cxx +++ b/src/db/update/Container.cxx @@ -75,9 +75,9 @@ UpdateWalk::UpdateContainerFile(Directory &directory, // shouldn't be necessary but it's there.. song->mtime = info.mtime; - FormatDefault(update_domain, "added %s/%s", - contdir->GetPath(), - song->filename.c_str()); + FormatNotice(update_domain, "added %s/%s", + contdir->GetPath(), + song->filename.c_str()); { const ScopeDatabaseLock protect; diff --git a/src/db/update/Remove.cxx b/src/db/update/Remove.cxx index 75ded4a0c..c1e61d1e1 100644 --- a/src/db/update/Remove.cxx +++ b/src/db/update/Remove.cxx @@ -41,7 +41,7 @@ UpdateRemoveService::RunDeferred() noexcept } for (const auto &uri : copy) { - FormatDefault(update_domain, "removing %s", uri.c_str()); + FormatNotice(update_domain, "removing %s", uri.c_str()); listener.OnDatabaseSongRemoved(uri.c_str()); } diff --git a/src/db/update/UpdateSong.cxx b/src/db/update/UpdateSong.cxx index f3b4d9362..f373cb2c7 100644 --- a/src/db/update/UpdateSong.cxx +++ b/src/db/update/UpdateSong.cxx @@ -76,11 +76,11 @@ try { } modified = true; - FormatDefault(update_domain, "added %s/%s", - directory.GetPath(), name); + FormatNotice(update_domain, "added %s/%s", + directory.GetPath(), name); } else if (info.mtime != song->mtime || walk_discard) { - FormatDefault(update_domain, "updating %s/%s", - directory.GetPath(), name); + FormatNotice(update_domain, "updating %s/%s", + directory.GetPath(), name); if (!song->UpdateFile(storage)) { FormatDebug(update_domain, "deleting unrecognized file %s/%s", diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx index e9b0feac9..21327012a 100644 --- a/src/decoder/plugins/FaadDecoderPlugin.cxx +++ b/src/decoder/plugins/FaadDecoderPlugin.cxx @@ -364,17 +364,17 @@ faad_stream_decode(DecoderClient &client, InputStream &is, } if (frame_info.channels != audio_format.channels) { - FormatDefault(faad_decoder_domain, - "channel count changed from %u to %u", - audio_format.channels, frame_info.channels); + FormatNotice(faad_decoder_domain, + "channel count changed from %u to %u", + audio_format.channels, frame_info.channels); break; } if (frame_info.samplerate != audio_format.sample_rate) { - FormatDefault(faad_decoder_domain, - "sample rate changed from %u to %lu", - audio_format.sample_rate, - (unsigned long)frame_info.samplerate); + FormatNotice(faad_decoder_domain, + "sample rate changed from %u to %lu", + audio_format.sample_rate, + (unsigned long)frame_info.samplerate); break; } diff --git a/src/output/Init.cxx b/src/output/Init.cxx index 93a98a152..bb48ebebd 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -62,15 +62,15 @@ FilteredAudioOutput::FilteredAudioOutput(const char *_plugin_name, static const AudioOutputPlugin * audio_output_detect() { - LogDefault(output_domain, "Attempt to detect audio output device"); + LogInfo(output_domain, "Attempt to detect audio output device"); audio_output_plugins_for_each(plugin) { if (plugin->test_default_device == nullptr) continue; - FormatDefault(output_domain, - "Attempting to detect a %s audio device", - plugin->name); + FormatInfo(output_domain, + "Attempting to detect a %s audio device", + plugin->name); if (ao_plugin_test_default_device(plugin)) return plugin; } @@ -289,9 +289,9 @@ audio_output_new(EventLoop &event_loop, plugin = audio_output_detect(); - FormatDefault(output_domain, - "Successfully detected a %s audio device", - plugin->name); + FormatNotice(output_domain, + "Successfully detected a %s audio device", + plugin->name); } std::unique_ptr ao(ao_plugin_init(event_loop, *plugin, diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index dfc89d30a..8c6da5405 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -376,7 +376,7 @@ mpd_jack_error(const char *msg) static void mpd_jack_info(const char *msg) { - LogDefault(jack_output_domain, msg); + LogNotice(jack_output_domain, msg); } #endif diff --git a/src/output/plugins/WasapiOutputPlugin.cxx b/src/output/plugins/WasapiOutputPlugin.cxx index 2aaebd91e..94fa1e647 100644 --- a/src/output/plugins/WasapiOutputPlugin.cxx +++ b/src/output/plugins/WasapiOutputPlugin.cxx @@ -322,8 +322,8 @@ void WasapiOutput::Enable() { if (enumerate_devices && SafeTry([this]() { EnumerateDevices(); })) { for (const auto &desc : device_desc) { - FormatDefault(wasapi_output_domain, "Device \"%u\" \"%s\"", - desc.first, desc.second.c_str()); + FormatNotice(wasapi_output_domain, "Device \"%u\" \"%s\"", + desc.first, desc.second.c_str()); } } diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 3a109f12d..4ab7c7e5d 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -964,7 +964,7 @@ Player::SongBorder() noexcept { const ScopeUnlock unlock(pc.mutex); - FormatDefault(player_domain, "played \"%s\"", song->GetURI()); + FormatNotice(player_domain, "played \"%s\"", song->GetURI()); ReplacePipe(dc.pipe); @@ -1135,7 +1135,7 @@ Player::Run() noexcept cross_fade_tag.reset(); if (song != nullptr) { - FormatDefault(player_domain, "played \"%s\"", song->GetURI()); + FormatNotice(player_domain, "played \"%s\"", song->GetURI()); song.reset(); } diff --git a/src/zeroconf/ZeroconfAvahi.cxx b/src/zeroconf/ZeroconfAvahi.cxx index 8f983bc93..c7ee5843f 100644 --- a/src/zeroconf/ZeroconfAvahi.cxx +++ b/src/zeroconf/ZeroconfAvahi.cxx @@ -59,9 +59,9 @@ AvahiGroupCallback(AvahiEntryGroup *g, switch (state) { case AVAHI_ENTRY_GROUP_ESTABLISHED: /* The entry group has been established successfully */ - FormatDefault(avahi_domain, - "Service '%s' successfully established.", - avahi_name); + FormatNotice(avahi_domain, + "Service '%s' successfully established.", + avahi_name); break; case AVAHI_ENTRY_GROUP_COLLISION: @@ -72,9 +72,9 @@ AvahiGroupCallback(AvahiEntryGroup *g, avahi_name = n; } - FormatDefault(avahi_domain, - "Service name collision, renaming service to '%s'", - avahi_name); + FormatNotice(avahi_domain, + "Service name collision, renaming service to '%s'", + avahi_name); /* And recreate the services */ AvahiRegisterService(avahi_entry_group_get_client(g)); @@ -171,8 +171,8 @@ MyAvahiClientCallback(AvahiClient *c, AvahiClientState state, case AVAHI_CLIENT_FAILURE: reason = avahi_client_errno(c); if (reason == AVAHI_ERR_DISCONNECTED) { - LogDefault(avahi_domain, - "Client Disconnected, will reconnect shortly"); + LogNotice(avahi_domain, + "Client Disconnected, will reconnect shortly"); if (avahi_group != nullptr) { avahi_entry_group_free(avahi_group); avahi_group = nullptr;