Commit ecf12a60 authored by Max Kellermann's avatar Max Kellermann

Log: add level "DEFAULT"

Map LogLevel::INFO to G_LOG_LEVEL_INFO, and LogLevel::DEFAULT to G_LOG_LEVEL_MESSAGE. Now client connect/disconnect message are only logged on log_level "secure".
parent 6de85cb0
......@@ -51,6 +51,9 @@ ToGLib(LogLevel level)
return G_LOG_LEVEL_DEBUG;
case LogLevel::INFO:
return G_LOG_LEVEL_INFO;
case LogLevel::DEFAULT:
return G_LOG_LEVEL_MESSAGE;
case LogLevel::WARNING:
......@@ -102,6 +105,15 @@ FormatInfo(const Domain &domain, const char *fmt, ...)
}
void
FormatDefault(const Domain &domain, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
LogFormatV(domain, LogLevel::DEFAULT, fmt, ap);
va_end(ap);
}
void
FormatWarning(const Domain &domain, const char *fmt, ...)
{
va_list ap;
......
......@@ -45,6 +45,11 @@ enum class LogLevel {
INFO,
/**
* Interesting informational message.
*/
DEFAULT,
/**
* Warning: something may be wrong.
*/
WARNING,
......@@ -84,6 +89,16 @@ void
FormatInfo(const Domain &domain, const char *fmt, ...);
static inline void
LogDefault(const Domain &domain, const char *msg)
{
Log(domain, LogLevel::DEFAULT, msg);
}
gcc_printf(2,3)
void
FormatDefault(const Domain &domain, const char *fmt, ...);
static inline void
LogWarning(const Domain &domain, const char *msg)
{
Log(domain, LogLevel::WARNING, msg);
......
......@@ -160,18 +160,18 @@ glue_db_init_and_load(void)
const struct config_param *path = config_get_param(CONF_DB_FILE);
if (param != nullptr && path != nullptr)
LogInfo(main_domain,
"Found both 'database' and 'db_file' setting - ignoring the latter");
LogWarning(main_domain,
"Found both 'database' and 'db_file' setting - ignoring the latter");
if (!mapper_has_music_directory()) {
if (param != nullptr)
LogInfo(main_domain,
"Found database setting without "
"music_directory - disabling database");
LogDefault(main_domain,
"Found database setting without "
"music_directory - disabling database");
if (path != nullptr)
LogInfo(main_domain,
"Found db_file setting without "
"music_directory - disabling database");
LogDefault(main_domain,
"Found db_file setting without "
"music_directory - disabling database");
return true;
}
......
......@@ -50,15 +50,15 @@
static const struct audio_output_plugin *
audio_output_detect(Error &error)
{
LogInfo(output_domain, "Attempt to detect audio output device");
LogDefault(output_domain, "Attempt to detect audio output device");
audio_output_plugins_for_each(plugin) {
if (plugin->test_default_device == nullptr)
continue;
FormatInfo(output_domain,
"Attempting to detect a %s audio device",
plugin->name);
FormatDefault(output_domain,
"Attempting to detect a %s audio device",
plugin->name);
if (ao_plugin_test_default_device(plugin))
return plugin;
}
......@@ -310,9 +310,9 @@ audio_output_new(const config_param &param,
if (plugin == nullptr)
return nullptr;
FormatInfo(output_domain,
"Successfully detected a %s audio device",
plugin->name);
FormatDefault(output_domain,
"Successfully detected a %s audio device",
plugin->name);
}
struct audio_output *ao = ao_plugin_init(plugin, param, error);
......
......@@ -875,7 +875,7 @@ Player::SongBorder()
{
const auto uri = song->GetURI();
FormatInfo(player_domain, "played \"%s\"", uri.c_str());
FormatDefault(player_domain, "played \"%s\"", uri.c_str());
}
ReplacePipe(dc.pipe);
......
......@@ -71,8 +71,8 @@ update_archive_tree(Directory &directory, const char *name)
db_unlock();
modified = true;
FormatInfo(update_domain, "added %s/%s",
directory.GetPath(), name);
FormatDefault(update_domain, "added %s/%s",
directory.GetPath(), name);
}
}
}
......
......@@ -112,8 +112,8 @@ update_container_file(Directory &directory,
modified = true;
FormatInfo(update_domain, "added %s/%s",
directory.GetPath(), vtrack);
FormatDefault(update_domain, "added %s/%s",
directory.GetPath(), vtrack);
g_free(vtrack);
}
......
......@@ -52,7 +52,7 @@ song_remove_event(void)
{
const auto uri = removed_song->GetURI();
FormatInfo(update_domain, "removing %s", uri.c_str());
FormatDefault(update_domain, "removing %s", uri.c_str());
}
#ifdef ENABLE_SQLITE
......
......@@ -83,11 +83,11 @@ update_song_file2(Directory &directory,
db_unlock();
modified = true;
FormatInfo(update_domain, "added %s/%s",
directory.GetPath(), name);
FormatDefault(update_domain, "added %s/%s",
directory.GetPath(), name);
} else if (st->st_mtime != song->mtime || walk_discard) {
FormatInfo(update_domain, "updating %s/%s",
directory.GetPath(), name);
FormatDefault(update_domain, "updating %s/%s",
directory.GetPath(), name);
if (!song->UpdateFile()) {
FormatDebug(update_domain,
"deleting unrecognized file %s/%s",
......
......@@ -61,9 +61,9 @@ static void avahiGroupCallback(AvahiEntryGroup * g,
switch (state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED:
/* The entry group has been established successfully */
FormatInfo(avahi_domain,
"Service '%s' successfully established.",
avahiName);
FormatDefault(avahi_domain,
"Service '%s' successfully established.",
avahiName);
break;
case AVAHI_ENTRY_GROUP_COLLISION:
......@@ -72,9 +72,9 @@ static void avahiGroupCallback(AvahiEntryGroup * g,
avahi_free(avahiName);
avahiName = n;
FormatInfo(avahi_domain,
"Service name collision, renaming service to '%s'",
avahiName);
FormatDefault(avahi_domain,
"Service name collision, renaming service to '%s'",
avahiName);
/* And recreate the services */
avahiRegisterService(avahi_entry_group_get_client(g));
......@@ -169,8 +169,8 @@ static void avahiClientCallback(AvahiClient * c, AvahiClientState state,
case AVAHI_CLIENT_FAILURE:
reason = avahi_client_errno(c);
if (reason == AVAHI_ERR_DISCONNECTED) {
LogInfo(avahi_domain,
"Client Disconnected, will reconnect shortly");
LogDefault(avahi_domain,
"Client Disconnected, will reconnect shortly");
if (avahiGroup) {
avahi_entry_group_free(avahiGroup);
avahiGroup = nullptr;
......
......@@ -50,8 +50,8 @@ ZeroconfInit(gcc_unused EventLoop &loop)
return;
if (listen_port <= 0) {
LogInfo(zeroconf_domain,
"No global port, disabling zeroconf");
LogWarning(zeroconf_domain,
"No global port, disabling zeroconf");
zeroconfEnabled = false;
return;
}
......
......@@ -427,17 +427,17 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
}
if (frame_info.channels != audio_format.channels) {
FormatInfo(faad_decoder_domain,
"channel count changed from %u to %u",
audio_format.channels, frame_info.channels);
FormatDefault(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) {
FormatInfo(faad_decoder_domain,
"sample rate changed from %u to %lu",
audio_format.sample_rate,
(unsigned long)frame_info.samplerate);
FormatDefault(faad_decoder_domain,
"sample rate changed from %u to %lu",
audio_format.sample_rate,
(unsigned long)frame_info.samplerate);
break;
}
......
......@@ -282,8 +282,8 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
if (len < 0) {
/* if error, we skip the frame */
LogInfo(ffmpeg_domain,
"decoding failed, frame skipped");
LogDefault(ffmpeg_domain,
"decoding failed, frame skipped");
break;
}
......
......@@ -221,7 +221,7 @@ mpd_jack_error(const char *msg)
static void
mpd_jack_info(const char *msg)
{
LogInfo(jack_output_domain, msg);
LogDefault(jack_output_domain, msg);
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment