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.
This commit is contained in:
Max Kellermann 2020-09-23 12:54:15 +02:00
parent e3106a019d
commit c843bce9f5
18 changed files with 60 additions and 58 deletions

View File

@ -83,12 +83,12 @@ log_level <default, secure, or verbose>
- :samp:`error`: errors - :samp:`error`: errors
- :samp:`warning`: warnings - :samp:`warning`: warnings
- :samp:`default`: interesting informational messages - :samp:`notice`: interesting informational messages
- :samp:`info`: unimportant informational messages - :samp:`info`: unimportant informational messages
- :samp:`verbose`: debug messages (for developers and for - :samp:`verbose`: debug messages (for developers and for
troubleshooting) troubleshooting)
The default is :samp:`default`. The default is :samp:`notice`.
follow_outside_symlinks <yes or no> follow_outside_symlinks <yes or no>
Control if MPD will follow symbolic links pointing outside the music dir. You Control if MPD will follow symbolic links pointing outside the music dir. You

View File

@ -92,7 +92,7 @@
# Suppress all messages below the given threshold. Use "verbose" for # Suppress all messages below the given threshold. Use "verbose" for
# troubleshooting. # troubleshooting.
# #
#log_level "default" #log_level "notice"
# #
# Setting "restore_paused" to "yes" puts MPD into pause mode instead # Setting "restore_paused" to "yes" puts MPD into pause mode instead
# of starting playback after startup. # of starting playback after startup.

View File

@ -65,11 +65,11 @@ FormatInfo(const Domain &domain, const char *fmt, ...) noexcept
} }
void void
FormatDefault(const Domain &domain, const char *fmt, ...) noexcept FormatNotice(const Domain &domain, const char *fmt, ...) noexcept
{ {
std::va_list ap; std::va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
LogFormatV(LogLevel::DEFAULT, domain, fmt, ap); LogFormatV(LogLevel::NOTICE, domain, fmt, ap);
va_end(ap); va_end(ap);
} }

View File

@ -77,14 +77,14 @@ void
FormatInfo(const Domain &domain, const char *fmt, ...) noexcept; FormatInfo(const Domain &domain, const char *fmt, ...) noexcept;
static inline void 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) gcc_printf(2,3)
void void
FormatDefault(const Domain &domain, const char *fmt, ...) noexcept; FormatNotice(const Domain &domain, const char *fmt, ...) noexcept;
static inline void static inline void
LogWarning(const Domain &domain, const char *msg) noexcept LogWarning(const Domain &domain, const char *msg) noexcept

View File

@ -47,7 +47,7 @@ ToAndroidLogLevel(LogLevel log_level) noexcept
return ANDROID_LOG_DEBUG; return ANDROID_LOG_DEBUG;
case LogLevel::INFO: case LogLevel::INFO:
case LogLevel::DEFAULT: case LogLevel::NOTICE:
return ANDROID_LOG_INFO; return ANDROID_LOG_INFO;
case LogLevel::WARNING: case LogLevel::WARNING:
@ -63,7 +63,7 @@ ToAndroidLogLevel(LogLevel log_level) noexcept
#else #else
static LogLevel log_threshold = LogLevel::DEFAULT; static LogLevel log_threshold = LogLevel::NOTICE;
static bool enable_timestamp; static bool enable_timestamp;
@ -122,7 +122,7 @@ ToSysLogLevel(LogLevel log_level) noexcept
case LogLevel::INFO: case LogLevel::INFO:
return LOG_INFO; return LOG_INFO;
case LogLevel::DEFAULT: case LogLevel::NOTICE:
return LOG_NOTICE; return LOG_NOTICE;
case LogLevel::WARNING: case LogLevel::WARNING:

View File

@ -95,8 +95,10 @@ log_init_file(int line)
static inline LogLevel static inline LogLevel
parse_log_level(const char *value) parse_log_level(const char *value)
{ {
if (StringIsEqual(value, "default")) if (StringIsEqual(value, "notice") ||
return LogLevel::DEFAULT; /* deprecated name: */
StringIsEqual(value, "default"))
return LogLevel::NOTICE;
else if (StringIsEqual(value, "info") || else if (StringIsEqual(value, "info") ||
/* deprecated since MPD 0.22: */ /* deprecated since MPD 0.22: */
StringIsEqual(value, "secure")) 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){ SetLogThreshold(config.With(ConfigOption::LOG_LEVEL, [](const char *s){
return s != nullptr return s != nullptr
? parse_log_level(s) ? parse_log_level(s)
: LogLevel::DEFAULT; : LogLevel::NOTICE;
})); }));
if (use_stdout) { if (use_stdout) {

View File

@ -42,7 +42,7 @@ enum class LogLevel {
/** /**
* Interesting informational message. * Interesting informational message.
*/ */
DEFAULT, NOTICE,
/** /**
* Warning: something may be wrong. * Warning: something may be wrong.

View File

@ -194,16 +194,16 @@ glue_db_init_and_load(Instance &instance, const ConfigData &config)
config); config);
if (instance.storage == nullptr) { if (instance.storage == nullptr) {
LogDefault(config_domain, LogNotice(config_domain,
"Found database setting without " "Found database setting without "
"music_directory - disabling database"); "music_directory - disabling database");
return true; return true;
} }
} else { } else {
if (IsStorageConfigured(config)) if (IsStorageConfigured(config))
LogDefault(config_domain, LogNotice(config_domain,
"Ignoring the storage configuration " "Ignoring the storage configuration "
"because the database does not need it"); "because the database does not need it");
} }
try { try {

View File

@ -82,8 +82,8 @@ UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
} }
modified = true; modified = true;
FormatDefault(update_domain, "added %s/%s", FormatNotice(update_domain, "added %s/%s",
directory.GetPath(), name); directory.GetPath(), name);
} }
} else { } else {
if (!song->UpdateFileInArchive(archive)) { if (!song->UpdateFileInArchive(archive)) {

View File

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

View File

@ -41,7 +41,7 @@ UpdateRemoveService::RunDeferred() noexcept
} }
for (const auto &uri : copy) { 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()); listener.OnDatabaseSongRemoved(uri.c_str());
} }

View File

@ -76,11 +76,11 @@ try {
} }
modified = true; modified = true;
FormatDefault(update_domain, "added %s/%s", FormatNotice(update_domain, "added %s/%s",
directory.GetPath(), name); directory.GetPath(), name);
} else if (info.mtime != song->mtime || walk_discard) { } else if (info.mtime != song->mtime || walk_discard) {
FormatDefault(update_domain, "updating %s/%s", FormatNotice(update_domain, "updating %s/%s",
directory.GetPath(), name); directory.GetPath(), name);
if (!song->UpdateFile(storage)) { if (!song->UpdateFile(storage)) {
FormatDebug(update_domain, FormatDebug(update_domain,
"deleting unrecognized file %s/%s", "deleting unrecognized file %s/%s",

View File

@ -364,17 +364,17 @@ faad_stream_decode(DecoderClient &client, InputStream &is,
} }
if (frame_info.channels != audio_format.channels) { if (frame_info.channels != audio_format.channels) {
FormatDefault(faad_decoder_domain, FormatNotice(faad_decoder_domain,
"channel count changed from %u to %u", "channel count changed from %u to %u",
audio_format.channels, frame_info.channels); audio_format.channels, frame_info.channels);
break; break;
} }
if (frame_info.samplerate != audio_format.sample_rate) { if (frame_info.samplerate != audio_format.sample_rate) {
FormatDefault(faad_decoder_domain, FormatNotice(faad_decoder_domain,
"sample rate changed from %u to %lu", "sample rate changed from %u to %lu",
audio_format.sample_rate, audio_format.sample_rate,
(unsigned long)frame_info.samplerate); (unsigned long)frame_info.samplerate);
break; break;
} }

View File

@ -62,15 +62,15 @@ FilteredAudioOutput::FilteredAudioOutput(const char *_plugin_name,
static const AudioOutputPlugin * static const AudioOutputPlugin *
audio_output_detect() 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) { audio_output_plugins_for_each(plugin) {
if (plugin->test_default_device == nullptr) if (plugin->test_default_device == nullptr)
continue; continue;
FormatDefault(output_domain, FormatInfo(output_domain,
"Attempting to detect a %s audio device", "Attempting to detect a %s audio device",
plugin->name); plugin->name);
if (ao_plugin_test_default_device(plugin)) if (ao_plugin_test_default_device(plugin))
return plugin; return plugin;
} }
@ -289,9 +289,9 @@ audio_output_new(EventLoop &event_loop,
plugin = audio_output_detect(); plugin = audio_output_detect();
FormatDefault(output_domain, FormatNotice(output_domain,
"Successfully detected a %s audio device", "Successfully detected a %s audio device",
plugin->name); plugin->name);
} }
std::unique_ptr<AudioOutput> ao(ao_plugin_init(event_loop, *plugin, std::unique_ptr<AudioOutput> ao(ao_plugin_init(event_loop, *plugin,

View File

@ -376,7 +376,7 @@ mpd_jack_error(const char *msg)
static void static void
mpd_jack_info(const char *msg) mpd_jack_info(const char *msg)
{ {
LogDefault(jack_output_domain, msg); LogNotice(jack_output_domain, msg);
} }
#endif #endif

View File

@ -322,8 +322,8 @@ void WasapiOutput::Enable() {
if (enumerate_devices && SafeTry([this]() { EnumerateDevices(); })) { if (enumerate_devices && SafeTry([this]() { EnumerateDevices(); })) {
for (const auto &desc : device_desc) { for (const auto &desc : device_desc) {
FormatDefault(wasapi_output_domain, "Device \"%u\" \"%s\"", FormatNotice(wasapi_output_domain, "Device \"%u\" \"%s\"",
desc.first, desc.second.c_str()); desc.first, desc.second.c_str());
} }
} }

View File

@ -964,7 +964,7 @@ Player::SongBorder() noexcept
{ {
const ScopeUnlock unlock(pc.mutex); const ScopeUnlock unlock(pc.mutex);
FormatDefault(player_domain, "played \"%s\"", song->GetURI()); FormatNotice(player_domain, "played \"%s\"", song->GetURI());
ReplacePipe(dc.pipe); ReplacePipe(dc.pipe);
@ -1135,7 +1135,7 @@ Player::Run() noexcept
cross_fade_tag.reset(); cross_fade_tag.reset();
if (song != nullptr) { if (song != nullptr) {
FormatDefault(player_domain, "played \"%s\"", song->GetURI()); FormatNotice(player_domain, "played \"%s\"", song->GetURI());
song.reset(); song.reset();
} }

View File

@ -59,9 +59,9 @@ AvahiGroupCallback(AvahiEntryGroup *g,
switch (state) { switch (state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED: case AVAHI_ENTRY_GROUP_ESTABLISHED:
/* The entry group has been established successfully */ /* The entry group has been established successfully */
FormatDefault(avahi_domain, FormatNotice(avahi_domain,
"Service '%s' successfully established.", "Service '%s' successfully established.",
avahi_name); avahi_name);
break; break;
case AVAHI_ENTRY_GROUP_COLLISION: case AVAHI_ENTRY_GROUP_COLLISION:
@ -72,9 +72,9 @@ AvahiGroupCallback(AvahiEntryGroup *g,
avahi_name = n; avahi_name = n;
} }
FormatDefault(avahi_domain, FormatNotice(avahi_domain,
"Service name collision, renaming service to '%s'", "Service name collision, renaming service to '%s'",
avahi_name); avahi_name);
/* And recreate the services */ /* And recreate the services */
AvahiRegisterService(avahi_entry_group_get_client(g)); AvahiRegisterService(avahi_entry_group_get_client(g));
@ -171,8 +171,8 @@ MyAvahiClientCallback(AvahiClient *c, AvahiClientState state,
case AVAHI_CLIENT_FAILURE: case AVAHI_CLIENT_FAILURE:
reason = avahi_client_errno(c); reason = avahi_client_errno(c);
if (reason == AVAHI_ERR_DISCONNECTED) { if (reason == AVAHI_ERR_DISCONNECTED) {
LogDefault(avahi_domain, LogNotice(avahi_domain,
"Client Disconnected, will reconnect shortly"); "Client Disconnected, will reconnect shortly");
if (avahi_group != nullptr) { if (avahi_group != nullptr) {
avahi_entry_group_free(avahi_group); avahi_entry_group_free(avahi_group);
avahi_group = nullptr; avahi_group = nullptr;