Skip to content
Snippets Groups Projects
Commit cef5695e authored by Marek Vavrusa's avatar Marek Vavrusa Committed by Gerrit Code Review
Browse files

Shorter log format, use ./configure --enable-shortlog

Shorter log format uses just seconds precision.

refs #2398

Fixed off-by-one.

Change-Id: Ie8fa417ac75c97be9be917833464b13591a661f2
parent 2af7f18a
No related merge requests found
......@@ -146,6 +146,11 @@ AC_ARG_ENABLE([lto],
*) AC_MSG_ERROR([bad value ${enableval} for --enable-lto]) ;;
esac])
# Check for shortlog
AC_ARG_ENABLE([shortlog],
AS_HELP_STRING([--enable-shortlog], [enable shorter date format in log messages [default=no]]),
AC_DEFINE([ENABLE_SHORTLOG], [1], [short log format]))
AX_CHECK_COMPILER_FLAGS("-fpredictive-commoning", [CFLAGS="$CFLAGS -fpredictive-commoning"], [])
# Disable strict aliasing
......
......@@ -220,15 +220,17 @@ static int _log_msg(logsrc_t src, int level, const char *msg)
time_t sec = tv.tv_sec;
if (localtime_r(&sec, &lt) != NULL) {
tlen = strftime(tstr, sizeof(tstr),
"%Y-%m-%dT%H:%M:%S", &lt);
"%Y-%m-%dT%H:%M:%S ", &lt);
#ifndef ENABLE_SHORTLOG
if (tlen > 0) {
char pm = (lt.tm_gmtoff > 0) ? '+' : '-';
snprintf(tstr + tlen, sizeof(tstr) - tlen,
snprintf(tstr + tlen - 1, sizeof(tstr) - tlen + 1,
".%.6lu%c%.2u:%.2u ",
(unsigned long)tv.tv_usec, pm,
(unsigned int)lt.tm_gmtoff / 3600,
(unsigned int)(lt.tm_gmtoff / 60) % 60);
}
#endif /* ENABLE_SHORTLOG */
}
// Log streams
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment