summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-12 17:16:34 +0200
committerThomas Haller <thaller@redhat.com>2018-10-18 12:16:55 +0200
commit884ed152618c669eebf21503822b9090f53162a3 (patch)
treef76c9ba50e6feb11ecf2de08070e751a33d92cab
parent5ac0f3bbe7e01bf6abe8c714307d5b1c6c604e32 (diff)
downloadNetworkManager-884ed152618c669eebf21503822b9090f53162a3.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.c12
-rw-r--r--src/nm-core-utils.h4
-rw-r--r--src/nm-logging.c21
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,