diff --git a/configure.ac b/configure.ac index 48c1989..7aa06cc 100644 --- a/configure.ac +++ b/configure.ac @@ -637,6 +637,28 @@ fi AM_CONDITIONAL(HAVE_TRACKER_FTS, test "$have_tracker_fts" = "yes") +################################################################## +# Check if we want log timestamps in UNIX time +################################################################## +AC_ARG_ENABLE([unix-timestamps], + AS_HELP_STRING([--enable-unix-timestamps], + [Use UNIX time for log timestamps [[default=no]]]),, + [enable_unix_timestamps=no]) + +if test "x$enable_unix_timestamps" != "xyes" ; then + have_unix_timestamps="no" +else + have_unix_timestamps="yes" +fi + +if test "x$have_unix_timestamps" = "xyes"; then + AC_DEFINE(HAVE_UNIX_TIMESTAMPS, [1], [Define to 1 if tracker will use UNIX timestamps]) +else + AC_DEFINE(HAVE_UNIX_TIMESTAMPS, [0], [Define to 0 if tracker will not use UNIX timestamps]) +fi + +AM_CONDITIONAL(HAVE_UNIX_TIMESTAMPS, test "$have_unix_timestamps" = "yes") + #################################################################### # Check for D-Bus requirements #################################################################### @@ -2123,6 +2145,7 @@ Build Configuration: Support for Cyrillic languages (enca): $have_enca Support for network status detection: $have_network_manager Unicode support library: $with_unicode_support + UNIX Timestamps: $have_unix_timestamps Applications: diff --git a/src/libtracker-common/tracker-log.c b/src/libtracker-common/tracker-log.c index 057f27b..894bc88 100644 --- a/src/libtracker-common/tracker-log.c +++ b/src/libtracker-common/tracker-log.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,9 @@ log_output (const gchar *domain, time_t now; gchar time_str[64]; gchar *output; +#if HAVE_UNIX_TIMESTAMPS == 0 struct tm *local_time; +#endif const gchar *log_level_str; static gsize size = 0; @@ -70,8 +73,12 @@ log_output (const gchar *domain, } now = time ((time_t *) NULL); +#if HAVE_UNIX_TIMESTAMPS == 1 + snprintf (time_str, 64, "%jd:", (intmax_t) now); +#else local_time = localtime (&now); strftime (time_str, 64, "%d %b %Y, %H:%M:%S:", local_time); +#endif switch (log_level) { case G_LOG_LEVEL_WARNING: