add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.
Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
diff --git a/src/logging.c b/src/logging.c
index 8a10133..9e30d5f 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -44,6 +44,7 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
#include <osmocom/vty/logging.h> /* for LOGGING_STR. */
@@ -268,7 +269,7 @@
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,