diff options
author | Thomas Haller <thaller@redhat.com> | 2016-02-05 10:49:48 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-02-05 11:10:38 +0100 |
commit | 04ec21ccc26e781ee950acd6d6eadcf289abddfe (patch) | |
tree | 9b0cb5b7ce9fcef674357afcb43fa56b42de7ba0 /src/nm-logging.c | |
parent | bd9479cc1a60df143f2e9167ef39b3c9be8aa300 (diff) | |
download | NetworkManager-04ec21ccc26e781ee950acd6d6eadcf289abddfe.tar.gz |
logging: add new logging macros _LOGx_err() to log errno
Not yet used, only implemented for nm-linux-platform.c as a
show case.
Use it like:
_LOGW_err (errno, "failed to popen()");
Diffstat (limited to 'src/nm-logging.c')
-rw-r--r-- | src/nm-logging.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c index 60ccb5cb2f..159d83fcf9 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -149,8 +149,14 @@ static char *_domains_to_string (gboolean include_level_override); static void _ensure_initialized (void) { - if (G_UNLIKELY (!global.logging_set_up)) + if (G_UNLIKELY (!global.logging_set_up)) { + int errsv = errno; + nm_logging_setup ("INFO", LOGD_DEFAULT_STRING, NULL, NULL); + + /* must ensure that errno is not modified. */ + errno = errsv; + } } static gboolean @@ -419,6 +425,7 @@ nm_logging_enabled (NMLogLevel level, NMLogDomain domain) if ((guint) level >= G_N_ELEMENTS (global.logging)) g_return_val_if_reached (FALSE); + /* This function is guaranteed not to modify errno. */ _ensure_initialized (); return !!(global.logging[level] & domain); |