summaryrefslogtreecommitdiff
path: root/src/nm-auth-manager.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-08-20 00:07:14 +0200
committerThomas Haller <thaller@redhat.com>2015-08-20 11:15:13 +0200
commitad7cdfc76678512988869607b0b614217f32903a (patch)
treefb200d8007ed6568334d4c2aedc2436c5661c567 /src/nm-auth-manager.c
parentb557f91a1bca67b05f69185f244319e764a4a21d (diff)
downloadNetworkManager-ad7cdfc76678512988869607b0b614217f32903a.tar.gz
logging: declare default logging macros in "nm-logging.h"
The logging macros _LOGD(), etc. are specific to each file as they format the message according to their context. Still, they were cumbersome to define and their implementation was repeated over and over (slightly different at times). Move the declaration of these macros to "nm-logging.h". The source file now only needs to define _NMLOG(), and either _NMLOG_ENABLED() or _NMLOG_DOMAIN. This reduces code duplication and encourages a common implementation and usage of these macros.
Diffstat (limited to 'src/nm-auth-manager.c')
-rw-r--r--src/nm-auth-manager.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/nm-auth-manager.c b/src/nm-auth-manager.c
index d429f43077..46a011205e 100644
--- a/src/nm-auth-manager.c
+++ b/src/nm-auth-manager.c
@@ -32,27 +32,21 @@
#define POLKIT_INTERFACE "org.freedesktop.PolicyKit1.Authority"
-#define _LOG_DEFAULT_DOMAIN LOGD_CORE
-
-#define _LOG(level, domain, ...) \
+#define _NMLOG_PREFIX_NAME "auth"
+#define _NMLOG_DOMAIN LOGD_CORE
+#define _NMLOG(level, ...) \
G_STMT_START { \
- if (nm_logging_enabled ((level), (domain))) { \
- char __prefix[30] = "auth"; \
+ if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \
+ char __prefix[30] = _NMLOG_PREFIX_NAME; \
\
if ((self) != singleton_instance) \
- g_snprintf (__prefix, sizeof (__prefix), "auth[%p]", (self)); \
- _nm_log ((level), (domain), 0, \
+ g_snprintf (__prefix, sizeof (__prefix), ""_NMLOG_PREFIX_NAME"[%p]", (self)); \
+ _nm_log ((level), (_NMLOG_DOMAIN), 0, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
} \
} G_STMT_END
-#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
-#define _LOGI(...) _LOG (LOGL_INFO, _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
-#define _LOGW(...) _LOG (LOGL_WARN, _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
-#define _LOGE(...) _LOG (LOGL_ERR, _LOG_DEFAULT_DOMAIN, __VA_ARGS__)
-
-
enum {
PROP_0,
PROP_POLKIT_ENABLED,