diff options
author | Thomas Haller <thaller@redhat.com> | 2018-10-12 17:16:34 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-10-17 18:06:13 +0200 |
commit | af5c6cd67ac88f276c76b6ba7b103cac39065756 (patch) | |
tree | f10eb9c0cd98305d40082665a7c0427a6a66acdd | |
parent | 9c80722f3a185193851f804c4752805fa1a437ce (diff) | |
download | NetworkManager-af5c6cd67ac88f276c76b6ba7b103cac39065756.tar.gz |
core: move logging of monotonic-timestamp to "nm-logging.c"
This makes monotonic-timestamp handling independent of "nm-logging.c".
-rw-r--r-- | src/nm-core-utils.c | 12 | ||||
-rw-r--r-- | src/nm-core-utils.h | 4 | ||||
-rw-r--r-- | src/nm-logging.c | 21 |
3 files changed, 26 insertions, 11 deletions
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 99fa8c9523..20d84e4627 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -1931,17 +1931,7 @@ monotonic_timestamp_get (struct timespec *tp) monotonic_timestamp_offset_sec = (- ((gint64) tp->tv_sec)) + 1; monotonic_timestamp_clock_mode = clock_mode; - if (nm_logging_enabled (LOGL_DEBUG, LOGD_CORE)) { - time_t now = time (NULL); - struct tm tm; - char s[255]; - - strftime (s, sizeof (s), "%Y-%m-%d %H:%M:%S", localtime_r (&now, &tm)); - nm_log_dbg (LOGD_CORE, "monotonic timestamp started counting 1.%09ld seconds ago with " - "an offset of %lld.0 seconds to %s (local time is %s)", - tp->tv_nsec, (long long) -monotonic_timestamp_offset_sec, - clock_mode == 1 ? "CLOCK_BOOTTIME" : "CLOCK_MONOTONIC", s); - } + _nm_utils_monotonic_timestamp_initialized (tp, monotonic_timestamp_offset_sec, clock_mode == 1); } /** diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h index 30d1360a1e..6800f070a1 100644 --- a/src/nm-core-utils.h +++ b/src/nm-core-utils.h @@ -253,6 +253,10 @@ nm_utils_get_monotonic_timestamp_ns_cached (gint64 *cache_now) ?: (*cache_now = nm_utils_get_monotonic_timestamp_ns ()); } +void _nm_utils_monotonic_timestamp_initialized (const struct timespec *tp, + gint64 offset_sec, + gboolean is_boottime); + gboolean nm_utils_is_valid_path_component (const char *name); const char *NM_ASSERT_VALID_PATH_COMPONENT (const char *name); diff --git a/src/nm-logging.c b/src/nm-logging.c index 9e7d389224..f80f28d934 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -744,6 +744,27 @@ _nm_log_impl (const char *file, /*****************************************************************************/ +void +_nm_utils_monotonic_timestamp_initialized (const struct timespec *tp, + gint64 offset_sec, + gboolean is_boottime) +{ + if (nm_logging_enabled (LOGL_DEBUG, LOGD_CORE)) { + time_t now = time (NULL); + struct tm tm; + char s[255]; + + strftime (s, sizeof (s), "%Y-%m-%d %H:%M:%S", localtime_r (&now, &tm)); + nm_log_dbg (LOGD_CORE, "monotonic timestamp started counting 1.%09ld seconds ago with " + "an offset of %lld.0 seconds to %s (local time is %s)", + tp->tv_nsec, + (long long) -offset_sec, + is_boottime ? "CLOCK_BOOTTIME" : "CLOCK_MONOTONIC", s); + } +} + +/*****************************************************************************/ + static void nm_log_handler (const char *log_domain, GLogLevelFlags level, |