Re: [systemd-devel] [PATCH] journalctl: add --utc option
On Thu, 02.10.14 12:51, Josh Triplett (j...@joshtriplett.org) wrote: On Thu, Oct 02, 2014 at 09:11:39PM +0200, Lennart Poettering wrote: On Thu, 02.10.14 11:56, Josh Triplett (j...@joshtriplett.org) wrote: On Thu, Oct 02, 2014 at 09:36:46AM +0200, Jan Synacek wrote: Introduce option to display time in UTC. Does TZ=UTC journalctl not do the right thing? A quick test here suggests that it does. That seems preferable to teaching individual tools to special-case UTC. Not sure i agree. --utc really should only have an effect on our own output, and that's a good thing. If you set $TZ you end up changing much much more, for example the logic of glibc's own syslog() and what it passes on, and we shouldn't influence that. True, but in the case of journalctl, which just queries and outputs journal data, what would TZ=UTC affect that you *wouldn't* want? journalctl shouldn't be calling syslog(). Well, who knows what is ultimately called. I mean, we fork off a $PAGER, which can be almost anything. We call into libraries and whatnot. All I am saying is that I think there's great value to keeping this as local as possible, and have this only effect the log display we do and nothing else. And beyond that: an environment variable is in many ways awful API, and non-discoverable. A command line switch is a lot more discoverable, as everybody knows to look for them in --help and in man pages. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] journalctl: add --utc option
On Thu, 02.10.14 09:36, Jan Synacek (jsyna...@redhat.com) wrote: Introduce option to display time in UTC. Looks generally OK. struct tm tm; +struct tm *(*gettime_r)(const time_t *, struct tm *); This isn't particularly beautiful and easy to grok, but certainly efficient. So, let's leave it in... r = -ENOENT; +gettime_r = (flags OUTPUT_UTC) ? gmtime_r : localtime_r; if (realtime) r = safe_atou64(realtime, x); @@ -329,17 +331,17 @@ static int output_short( switch(mode) { case OUTPUT_SHORT_ISO: -r = strftime(buf, sizeof(buf), %Y-%m-%dT%H:%M:%S%z, localtime_r(t, tm)); +r = strftime(buf, sizeof(buf), %Y-%m-%dT%H:%M:%S%z, gettime_r(t, tm)); break; case OUTPUT_SHORT_PRECISE: -r = strftime(buf, sizeof(buf), %b %d %H:%M:%S, localtime_r(t, tm)); +r = strftime(buf, sizeof(buf), %b %d %H:%M:%S, gettime_r(t, tm)); if (r 0) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), .%06llu, (unsigned long long) (x % USEC_PER_SEC)); } break; default: -r = strftime(buf, sizeof(buf), %b %d %H:%M:%S, localtime_r(t, tm)); +r = strftime(buf, sizeof(buf), %b %d %H:%M:%S, gettime_r(t, tm)); } if (r = 0) { diff --git a/src/shared/output-mode.h b/src/shared/output-mode.h index ac1bb01..8f78aac 100644 --- a/src/shared/output-mode.h +++ b/src/shared/output-mode.h @@ -26,6 +26,7 @@ typedef enum OutputMode { OUTPUT_SHORT_ISO, OUTPUT_SHORT_PRECISE, OUTPUT_SHORT_MONOTONIC, +OUTPUT_UTC, OUTPUT_VERBOSE, OUTPUT_EXPORT, OUTPUT_JSON, This should not be part of OutputMode, but of OutputFlags! Otherwise looks good. Do you have commit access? If so, please push after fixing the issue above. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] journalctl: add --utc option
On Thu, Oct 02, 2014 at 09:36:46AM +0200, Jan Synacek wrote: Introduce option to display time in UTC. Does TZ=UTC journalctl not do the right thing? A quick test here suggests that it does. That seems preferable to teaching individual tools to special-case UTC. - Josh Triplett ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] journalctl: add --utc option
On Thu, 02.10.14 11:56, Josh Triplett (j...@joshtriplett.org) wrote: On Thu, Oct 02, 2014 at 09:36:46AM +0200, Jan Synacek wrote: Introduce option to display time in UTC. Does TZ=UTC journalctl not do the right thing? A quick test here suggests that it does. That seems preferable to teaching individual tools to special-case UTC. Not sure i agree. --utc really should only have an effect on our own output, and that's a good thing. If you set $TZ you end up changing much much more, for example the logic of glibc's own syslog() and what it passes on, and we shouldn't influence that. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] journalctl: add --utc option
On Thu, Oct 02, 2014 at 09:11:39PM +0200, Lennart Poettering wrote: On Thu, 02.10.14 11:56, Josh Triplett (j...@joshtriplett.org) wrote: On Thu, Oct 02, 2014 at 09:36:46AM +0200, Jan Synacek wrote: Introduce option to display time in UTC. Does TZ=UTC journalctl not do the right thing? A quick test here suggests that it does. That seems preferable to teaching individual tools to special-case UTC. Not sure i agree. --utc really should only have an effect on our own output, and that's a good thing. If you set $TZ you end up changing much much more, for example the logic of glibc's own syslog() and what it passes on, and we shouldn't influence that. True, but in the case of journalctl, which just queries and outputs journal data, what would TZ=UTC affect that you *wouldn't* want? journalctl shouldn't be calling syslog(). - Josh Triplett ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel