summaryrefslogtreecommitdiff
path: root/src/shared/logs-show.c
diff options
context:
space:
mode:
authorTomasz Torcz <tomek@pipebreaker.pl>2013-07-18 10:21:45 +0200
committerLennart Poettering <lennart@poettering.net>2013-07-18 15:58:49 +0200
commit44bc6e1fe0171af19451b5586f7fdd08853ccf5b (patch)
treea4e8dbd6aafce351a3d428bf9156cc833f39f281 /src/shared/logs-show.c
parent884c86812c51479496edd50b278383d7bb67baf0 (diff)
journalctl: add ”short-iso” output format with verbose ISO8601 timestamps
Example: 2013-07-18T10:10:01+0200 sandworm CROND[20957]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r--src/shared/logs-show.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index ea4746879b..bd7363aa82 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -273,9 +273,14 @@ static int output_short(
}
t = (time_t) (x / USEC_PER_SEC);
- if (strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm)) <= 0) {
+ if (mode == OUTPUT_SHORT_ISO)
+ r = strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", localtime_r(&t, &tm));
+ else
+ r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm));
+
+ if (r <= 0) {
log_error("Failed to format time.");
- return r;
+ return -EINVAL;
}
fputs(buf, f);
@@ -798,6 +803,7 @@ static int (*output_funcs[_OUTPUT_MODE_MAX])(
[OUTPUT_SHORT] = output_short,
[OUTPUT_SHORT_MONOTONIC] = output_short,
+ [OUTPUT_SHORT_ISO] = output_short,
[OUTPUT_VERBOSE] = output_verbose,
[OUTPUT_EXPORT] = output_export,
[OUTPUT_JSON] = output_json,
@@ -1076,6 +1082,7 @@ int show_journal_by_unit(
static const char *const output_mode_table[_OUTPUT_MODE_MAX] = {
[OUTPUT_SHORT] = "short",
[OUTPUT_SHORT_MONOTONIC] = "short-monotonic",
+ [OUTPUT_SHORT_ISO] = "short-iso",
[OUTPUT_VERBOSE] = "verbose",
[OUTPUT_EXPORT] = "export",
[OUTPUT_JSON] = "json",