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".
This commit is contained in:
parent
6de85cb047
commit
ecf12a60e8
12
src/Log.cxx
12
src/Log.cxx
@ -51,6 +51,9 @@ ToGLib(LogLevel level)
|
|||||||
return G_LOG_LEVEL_DEBUG;
|
return G_LOG_LEVEL_DEBUG;
|
||||||
|
|
||||||
case LogLevel::INFO:
|
case LogLevel::INFO:
|
||||||
|
return G_LOG_LEVEL_INFO;
|
||||||
|
|
||||||
|
case LogLevel::DEFAULT:
|
||||||
return G_LOG_LEVEL_MESSAGE;
|
return G_LOG_LEVEL_MESSAGE;
|
||||||
|
|
||||||
case LogLevel::WARNING:
|
case LogLevel::WARNING:
|
||||||
@ -101,6 +104,15 @@ FormatInfo(const Domain &domain, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
FormatWarning(const Domain &domain, const char *fmt, ...)
|
FormatWarning(const Domain &domain, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
15
src/Log.hxx
15
src/Log.hxx
@ -44,6 +44,11 @@ enum class LogLevel {
|
|||||||
*/
|
*/
|
||||||
INFO,
|
INFO,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interesting informational message.
|
||||||
|
*/
|
||||||
|
DEFAULT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warning: something may be wrong.
|
* Warning: something may be wrong.
|
||||||
*/
|
*/
|
||||||
@ -83,6 +88,16 @@ gcc_printf(2,3)
|
|||||||
void
|
void
|
||||||
FormatInfo(const Domain &domain, const char *fmt, ...);
|
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
|
static inline void
|
||||||
LogWarning(const Domain &domain, const char *msg)
|
LogWarning(const Domain &domain, const char *msg)
|
||||||
{
|
{
|
||||||
|
16
src/Main.cxx
16
src/Main.cxx
@ -160,18 +160,18 @@ glue_db_init_and_load(void)
|
|||||||
const struct config_param *path = config_get_param(CONF_DB_FILE);
|
const struct config_param *path = config_get_param(CONF_DB_FILE);
|
||||||
|
|
||||||
if (param != nullptr && path != nullptr)
|
if (param != nullptr && path != nullptr)
|
||||||
LogInfo(main_domain,
|
LogWarning(main_domain,
|
||||||
"Found both 'database' and 'db_file' setting - ignoring the latter");
|
"Found both 'database' and 'db_file' setting - ignoring the latter");
|
||||||
|
|
||||||
if (!mapper_has_music_directory()) {
|
if (!mapper_has_music_directory()) {
|
||||||
if (param != nullptr)
|
if (param != nullptr)
|
||||||
LogInfo(main_domain,
|
LogDefault(main_domain,
|
||||||
"Found database setting without "
|
"Found database setting without "
|
||||||
"music_directory - disabling database");
|
"music_directory - disabling database");
|
||||||
if (path != nullptr)
|
if (path != nullptr)
|
||||||
LogInfo(main_domain,
|
LogDefault(main_domain,
|
||||||
"Found db_file setting without "
|
"Found db_file setting without "
|
||||||
"music_directory - disabling database");
|
"music_directory - disabling database");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@
|
|||||||
static const struct audio_output_plugin *
|
static const struct audio_output_plugin *
|
||||||
audio_output_detect(Error &error)
|
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) {
|
audio_output_plugins_for_each(plugin) {
|
||||||
if (plugin->test_default_device == nullptr)
|
if (plugin->test_default_device == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FormatInfo(output_domain,
|
FormatDefault(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;
|
||||||
}
|
}
|
||||||
@ -310,9 +310,9 @@ audio_output_new(const config_param ¶m,
|
|||||||
if (plugin == nullptr)
|
if (plugin == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
FormatInfo(output_domain,
|
FormatDefault(output_domain,
|
||||||
"Successfully detected a %s audio device",
|
"Successfully detected a %s audio device",
|
||||||
plugin->name);
|
plugin->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct audio_output *ao = ao_plugin_init(plugin, param, error);
|
struct audio_output *ao = ao_plugin_init(plugin, param, error);
|
||||||
|
@ -875,7 +875,7 @@ Player::SongBorder()
|
|||||||
|
|
||||||
{
|
{
|
||||||
const auto uri = song->GetURI();
|
const auto uri = song->GetURI();
|
||||||
FormatInfo(player_domain, "played \"%s\"", uri.c_str());
|
FormatDefault(player_domain, "played \"%s\"", uri.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplacePipe(dc.pipe);
|
ReplacePipe(dc.pipe);
|
||||||
|
@ -71,8 +71,8 @@ update_archive_tree(Directory &directory, const char *name)
|
|||||||
db_unlock();
|
db_unlock();
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
FormatInfo(update_domain, "added %s/%s",
|
FormatDefault(update_domain, "added %s/%s",
|
||||||
directory.GetPath(), name);
|
directory.GetPath(), name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,8 +112,8 @@ update_container_file(Directory &directory,
|
|||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
FormatInfo(update_domain, "added %s/%s",
|
FormatDefault(update_domain, "added %s/%s",
|
||||||
directory.GetPath(), vtrack);
|
directory.GetPath(), vtrack);
|
||||||
g_free(vtrack);
|
g_free(vtrack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ song_remove_event(void)
|
|||||||
|
|
||||||
{
|
{
|
||||||
const auto uri = removed_song->GetURI();
|
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
|
#ifdef ENABLE_SQLITE
|
||||||
|
@ -83,11 +83,11 @@ update_song_file2(Directory &directory,
|
|||||||
db_unlock();
|
db_unlock();
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
FormatInfo(update_domain, "added %s/%s",
|
FormatDefault(update_domain, "added %s/%s",
|
||||||
directory.GetPath(), name);
|
directory.GetPath(), name);
|
||||||
} else if (st->st_mtime != song->mtime || walk_discard) {
|
} else if (st->st_mtime != song->mtime || walk_discard) {
|
||||||
FormatInfo(update_domain, "updating %s/%s",
|
FormatDefault(update_domain, "updating %s/%s",
|
||||||
directory.GetPath(), name);
|
directory.GetPath(), name);
|
||||||
if (!song->UpdateFile()) {
|
if (!song->UpdateFile()) {
|
||||||
FormatDebug(update_domain,
|
FormatDebug(update_domain,
|
||||||
"deleting unrecognized file %s/%s",
|
"deleting unrecognized file %s/%s",
|
||||||
|
@ -61,9 +61,9 @@ static void 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 */
|
||||||
FormatInfo(avahi_domain,
|
FormatDefault(avahi_domain,
|
||||||
"Service '%s' successfully established.",
|
"Service '%s' successfully established.",
|
||||||
avahiName);
|
avahiName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AVAHI_ENTRY_GROUP_COLLISION:
|
case AVAHI_ENTRY_GROUP_COLLISION:
|
||||||
@ -72,9 +72,9 @@ static void avahiGroupCallback(AvahiEntryGroup * g,
|
|||||||
avahi_free(avahiName);
|
avahi_free(avahiName);
|
||||||
avahiName = n;
|
avahiName = n;
|
||||||
|
|
||||||
FormatInfo(avahi_domain,
|
FormatDefault(avahi_domain,
|
||||||
"Service name collision, renaming service to '%s'",
|
"Service name collision, renaming service to '%s'",
|
||||||
avahiName);
|
avahiName);
|
||||||
|
|
||||||
/* And recreate the services */
|
/* And recreate the services */
|
||||||
avahiRegisterService(avahi_entry_group_get_client(g));
|
avahiRegisterService(avahi_entry_group_get_client(g));
|
||||||
@ -169,8 +169,8 @@ static void avahiClientCallback(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) {
|
||||||
LogInfo(avahi_domain,
|
LogDefault(avahi_domain,
|
||||||
"Client Disconnected, will reconnect shortly");
|
"Client Disconnected, will reconnect shortly");
|
||||||
if (avahiGroup) {
|
if (avahiGroup) {
|
||||||
avahi_entry_group_free(avahiGroup);
|
avahi_entry_group_free(avahiGroup);
|
||||||
avahiGroup = nullptr;
|
avahiGroup = nullptr;
|
||||||
|
@ -50,8 +50,8 @@ ZeroconfInit(gcc_unused EventLoop &loop)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (listen_port <= 0) {
|
if (listen_port <= 0) {
|
||||||
LogInfo(zeroconf_domain,
|
LogWarning(zeroconf_domain,
|
||||||
"No global port, disabling zeroconf");
|
"No global port, disabling zeroconf");
|
||||||
zeroconfEnabled = false;
|
zeroconfEnabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -427,17 +427,17 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (frame_info.channels != audio_format.channels) {
|
if (frame_info.channels != audio_format.channels) {
|
||||||
FormatInfo(faad_decoder_domain,
|
FormatDefault(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) {
|
||||||
FormatInfo(faad_decoder_domain,
|
FormatDefault(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,8 +282,8 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
|
|||||||
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
/* if error, we skip the frame */
|
/* if error, we skip the frame */
|
||||||
LogInfo(ffmpeg_domain,
|
LogDefault(ffmpeg_domain,
|
||||||
"decoding failed, frame skipped");
|
"decoding failed, frame skipped");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ mpd_jack_error(const char *msg)
|
|||||||
static void
|
static void
|
||||||
mpd_jack_info(const char *msg)
|
mpd_jack_info(const char *msg)
|
||||||
{
|
{
|
||||||
LogInfo(jack_output_domain, msg);
|
LogDefault(jack_output_domain, msg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user