From 529d905bd024c6fde6c7e7d0ba9bfdd708c1f6cf Mon Sep 17 00:00:00 2001 From: jfreegman Date: Mon, 7 Mar 2022 11:26:44 -0500 Subject: [PATCH] Add timestamps to logger and enable widechar for bazel build --- BUILD.bazel | 1 + src/toxic.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/BUILD.bazel b/BUILD.bazel index 1e832aa..48102f1 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -21,6 +21,7 @@ cc_binary( "-std=gnu99", "-DAUDIO", "-DGAMES", + "-DHAVE_WIDECHAR", "-DPACKAGE_DATADIR='\"data\"'", "-DPYTHON", "-DQRCODE", diff --git a/src/toxic.c b/src/toxic.c index 33a6e8f..13beeb6 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -267,7 +267,12 @@ void cb_toxcore_logger(Tox *m, TOX_LOG_LEVEL level, const char *file, uint32_t l fp = stderr; } - fprintf(fp, "[%c] %s:%u(%s) - %s\n", tox_log_level_show(level)[0], file, line, func, message); + const time_t t = time(NULL); + struct tm *tmp = gmtime(&t); + char timestamp[200]; + strftime(timestamp, sizeof(timestamp), "%F %T", tmp); + + fprintf(fp, "[%c] %s %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, file, line, func, message); fflush(fp); }