From 8e2f7e87f4d854e697c40545326a16e50614dd5c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 22 Sep 2016 03:58:13 +0200 Subject: add osmo_gettimeofday as a shim around gettimeofday This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089 --- src/logging.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/logging.c') diff --git a/src/logging.c b/src/logging.c index 8a101337..9e30d5f8 100644 --- a/src/logging.c +++ b/src/logging.c @@ -44,6 +44,7 @@ #include #include #include +#include #include /* for LOGGING_STR. */ @@ -268,7 +269,7 @@ static void _output(struct log_target *target, unsigned int subsys, if (target->print_ext_timestamp) { struct tm tm; struct timeval tv; - gettimeofday(&tv, NULL); + osmo_gettimeofday(&tv, NULL); localtime_r(&tv.tv_sec, &tm); ret = snprintf(buf + offset, rem, "%04d%02d%02d%02d%02d%02d%03d ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, -- cgit v1.2.3