diff options
author | Thomas Haller <thaller@redhat.com> | 2016-03-01 10:17:44 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-03-01 12:42:42 +0100 |
commit | e4a7502a2c85a09f7eceeff34ad47ac5f0e01e67 (patch) | |
tree | 502232ceb3155fd23b32773baa2aafe4405e9d2b | |
parent | 60ca6e028f2d3be8718e069d762504c3104a2d3a (diff) | |
download | NetworkManager-e4a7502a2c85a09f7eceeff34ad47ac5f0e01e67.tar.gz |
logging: make logging independent of platform
"nm-logging.h" is a basic core module that should have few other
dependencies. Instead of letting nm-logging.c directly call a function
from "nm-linux-platform.c", let platform register a handler as needed.
This way, you can build a core library containing nm-logging but no
nm-platform.
-rw-r--r-- | src/nm-logging.c | 6 | ||||
-rw-r--r-- | src/nm-logging.h | 2 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.c | 5 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.h | 2 |
4 files changed, 9 insertions, 6 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c index 4e56723b7f..e086ecd4ca 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -39,7 +39,6 @@ #include "nm-errors.h" #include "NetworkManagerUtils.h" -#include "nm-linux-platform.h" typedef enum { LOG_FORMAT_FLAG_NONE = 0, @@ -71,6 +70,8 @@ typedef enum { LOG_FORMAT_FLAG_ALIGN_LOCATION, } LogFormatFlags; +void (*_nm_logging_clear_platform_logging_cache) (void); + static void nm_log_handler (const gchar *log_domain, GLogLevelFlags level, @@ -332,11 +333,12 @@ nm_logging_setup (const char *level, global.logging[i] = new_logging[i]; if ( had_platform_debug + && _nm_logging_clear_platform_logging_cache && !nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) { /* when debug logging is enabled, platform will cache all access to * sysctl. When the user disables debug-logging, we want to clear that * cache right away. */ - _nm_linux_platform_sysctl_clear_cache (); + _nm_logging_clear_platform_logging_cache (); } if (unrecognized) diff --git a/src/nm-logging.h b/src/nm-logging.h index 333f4f5a95..97102770c5 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -243,6 +243,8 @@ void nm_logging_syslog_openlog (const char *logging_backend); #define _LOG2t_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END #endif +extern void (*_nm_logging_clear_platform_logging_cache) (void); + /*****************************************************************************/ #endif /* __NETWORKMANAGER_LOGGING_H__ */ diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index b3a8c4aa73..637012c69c 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2520,8 +2520,8 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value) static GSList *sysctl_clear_cache_list; -void -_nm_linux_platform_sysctl_clear_cache (void) +static void +_nm_logging_clear_platform_logging_cache_impl (void) { while (sysctl_clear_cache_list) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (sysctl_clear_cache_list->data); @@ -2541,6 +2541,7 @@ _log_dbg_sysctl_get_impl (NMPlatform *platform, const char *path, const char *co const char *prev_value = NULL; if (!priv->sysctl_get_prev_values) { + _nm_logging_clear_platform_logging_cache = _nm_logging_clear_platform_logging_cache_impl; sysctl_clear_cache_list = g_slist_prepend (sysctl_clear_cache_list, platform); priv->sysctl_get_prev_values = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); } else diff --git a/src/platform/nm-linux-platform.h b/src/platform/nm-linux-platform.h index 81f9c73871..a9e2cd82f9 100644 --- a/src/platform/nm-linux-platform.h +++ b/src/platform/nm-linux-platform.h @@ -50,6 +50,4 @@ GType nm_linux_platform_get_type (void); void nm_linux_platform_setup (void); -void _nm_linux_platform_sysctl_clear_cache (void); - #endif /* __NETWORKMANAGER_LINUX_PLATFORM_H__ */ |