Skip to content

Commit

Permalink
Tune diagnostic logging
Browse files Browse the repository at this point in the history
Do not complain about missing evdev event mapping configuration as it
is optional.

Use LOG_NOTICE rather than LOG_CRIT when emitting extra diagnostic
messages from mce devel builds to stop journalctl from highlighting
them.

Promote logging of infrequent but important system state changes to
NOTICE level.

Promote logging of system upgrade related state changes to WARN level
so that in the future diagnostics are available from both existing
and upgraded versions in case update problems need to be analyzed.

Demote display state request filtering to DEBUG as it is needed only
when debugging specific problems.
  • Loading branch information
spiiroin committed Jan 16, 2015
1 parent 6a50ff9 commit 5fb8464
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
3 changes: 3 additions & 0 deletions event-input.c
Expand Up @@ -801,6 +801,9 @@ evin_event_mapper_init(void)
gsize count = 0;
gsize valid = 0;

if( !mce_conf_has_group(grp) )
goto EXIT;

keys = mce_conf_get_keys(grp, &count);

if( !keys || !count )
Expand Down
12 changes: 8 additions & 4 deletions mce-log.c
Expand Up @@ -80,8 +80,8 @@ static void timestamp(struct timeval *tv)
*/
static loglevel_t mce_log_level_normalize(loglevel_t loglevel)
{
if( loglevel < LL_ALERT ) {
loglevel = LL_ALERT;
if( loglevel < LL_EXTRA ) {
loglevel = LL_EXTRA;
}
else if( loglevel > LL_DEBUG ) {
loglevel = LL_DEBUG;
Expand All @@ -99,7 +99,7 @@ static const char *mce_log_level_tag(loglevel_t loglevel)
{
const char *res = "?";
switch( loglevel ) {
case LL_ALERT: res = "A"; break;
case LL_EXTRA: res = "X"; break;
case LL_CRIT: res = "C"; break;
case LL_ERR: res = "E"; break;
case LL_WARN: res = "W"; break;
Expand Down Expand Up @@ -193,6 +193,10 @@ void mce_log_file(loglevel_t loglevel, const char *const file,
mce_log_level_tag(loglevel),
msg);
} else {
/* LL_EXTRA = devel flavor notice */
if( loglevel == LL_EXTRA )
loglevel = LL_NOTICE;

/* loglevels are subset of syslog priorities, so
* we can use loglevel as is for syslog priority */
syslog(loglevel, "%s", msg);
Expand Down Expand Up @@ -303,7 +307,7 @@ int mce_log_p_(const loglevel_t loglevel,
return true;
}

if( loglevel < LL_CRIT )
if( loglevel < LL_EXTRA )
return logverbosity >= LL_NOTICE;

return logverbosity >= loglevel;
Expand Down
4 changes: 2 additions & 2 deletions mce-log.h
Expand Up @@ -29,7 +29,7 @@
/** Severity of loglevels (subset of syslog priorities) */
typedef enum {
LL_NONE = 0, /**< No logging at all */
LL_ALERT = LOG_ALERT, /**< Alert */
LL_EXTRA = LOG_ALERT, /**< Placeholder for devel logging */
LL_CRIT = LOG_CRIT, /**< Critical error */
LL_ERR = LOG_ERR, /**< Error */
LL_WARN = LOG_WARNING, /**< Warning */
Expand All @@ -40,7 +40,7 @@ typedef enum {
LL_DEFAULT = LL_WARN, /**< Default log level */

# ifdef ENABLE_DEVEL_LOGGING
LL_DEVEL = LL_CRIT, /**< Log by default on devel build */
LL_DEVEL = LL_EXTRA, /**< Log by default on devel build */
# else
LL_DEVEL = LL_NOTICE, /**< Otherwise verbose mode needed */
# endif
Expand Down
2 changes: 1 addition & 1 deletion mce.c
Expand Up @@ -918,7 +918,7 @@ int main(int argc, char **argv)
/* Identify mce version & flavor on start up */
mce_log(LL_WARN, "MCE %s (%s) starting up",
G_STRINGIFY(PRG_VERSION),
(LL_DEVEL == LL_CRIT) ? "devel" : "release");
(LL_DEVEL == LL_EXTRA) ? "devel" : "release");

/* Daemonize if requested */
if( mce_args.daemonflag )
Expand Down
19 changes: 12 additions & 7 deletions modules/display.c
Expand Up @@ -1002,7 +1002,8 @@ static void mdy_datapipe_packagekit_locked_cb(gconstpointer data)
if( packagekit_locked == prev )
goto EXIT;

mce_log(LL_DEBUG, "packagekit_locked = %d", packagekit_locked);
/* Log by default as it might help analyzing upgrade problems */
mce_log(LL_WARN, "packagekit_locked = %d", packagekit_locked);

/* re-evaluate suspend policy */
mdy_stm_schedule_rethink();
Expand All @@ -1027,7 +1028,7 @@ static void mdy_datapipe_system_state_cb(gconstpointer data)
if( system_state == prev )
goto EXIT;

mce_log(LL_DEBUG, "system_state = %d", system_state);
mce_log(LL_NOTICE, "system_state = %d", system_state);

switch( system_state ) {
case MCE_STATE_ACTDEAD:
Expand Down Expand Up @@ -1159,7 +1160,7 @@ static gpointer mdy_datapipe_display_state_filter_cb(gpointer data)
if( mdy_use_low_power_mode && mdy_low_power_mode_supported )
break;

mce_log(LL_WARN, "reject low power mode display request");
mce_log(LL_DEBUG, "reject low power mode display request");
next_state = MCE_DISPLAY_OFF;
goto UPDATE;

Expand Down Expand Up @@ -1191,7 +1192,7 @@ static gpointer mdy_datapipe_display_state_filter_cb(gpointer data)

UPDATE:
if( want_state != next_state ) {
mce_log(LL_WARN, "requested: %s, granted: %s",
mce_log(LL_DEBUG, "requested: %s, granted: %s",
mdy_display_state_name(want_state),
mdy_display_state_name(next_state));
}
Expand Down Expand Up @@ -7521,7 +7522,7 @@ static gboolean mdy_dbus_handle_desktop_started_sig(DBusMessage *const msg)

(void)msg;

mce_log(LL_DEBUG, "Received desktop startup notification");
mce_log(LL_NOTICE, "Received desktop startup notification");

mce_log(LL_DEBUG, "deactivate MCE_LED_PATTERN_POWER_ON");
execute_datapipe_output_triggers(&led_pattern_deactivate_pipe,
Expand Down Expand Up @@ -7799,7 +7800,7 @@ static void mdy_flagfiles_init_done_cb(const char *path,

if( mdy_init_done != flag ) {
mdy_init_done = flag;
mce_log(LL_NOTICE, "mdy_init_done -> %s",
mce_log(LL_NOTICE, "init_done flag file present: %s",
mdy_init_done ? "true" : "false");
mdy_stm_schedule_rethink();
#ifdef ENABLE_CPU_GOVERNOR
Expand Down Expand Up @@ -7828,7 +7829,9 @@ static void mdy_flagfiles_update_mode_cb(const char *path,

if( mdy_update_mode != flag ) {
mdy_update_mode = flag;
mce_log(LL_DEVEL, "mdy_update_mode -> %s",

/* Log by default as it might help analyzing upgrade problems */
mce_log(LL_WARN, "update_mode flag file present: %s",
mdy_update_mode ? "true" : "false");

if( mdy_update_mode ) {
Expand Down Expand Up @@ -7888,6 +7891,8 @@ static void mdy_flagfiles_bootstate_cb(const char *path,
buff[rc] = 0;
buff[strcspn(buff, "\r\n")] = 0;

mce_log(LL_NOTICE, "bootstate flag file content: %s", buff);

/* for now we only need to differentiate USER and not USER */
if( !strcmp(buff, "BOOTSTATE=USER") )
mdy_bootstate = BOOTSTATE_USER;
Expand Down

0 comments on commit 5fb8464

Please sign in to comment.