summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-08-07 22:55:29 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-08-20 21:18:44 -0400
commitcf40f0be1acc73ea7dfb9aabc213f6a762ea62d2 (patch)
tree1ac99638e4caaca9ac6c743cc5d75aaca1accbd9 /src/shared
parentf02d836794d519e717e51d81501557da55915ce2 (diff)
logs-show: show source timestamp in verbose mode
This makes verbose behave like short mode, i.e. try to show the source timestamp, and fall back to journald timestamp only if unavailable or unparsable. I think verbose should be like short, only showing more fields, and showing different timestamps would be confusing.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/logs-show.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 7002675301..89a73a5860 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -399,11 +399,35 @@ static int output_verbose(
sd_journal_set_data_threshold(j, 0);
- r = sd_journal_get_realtime_usec(j, &realtime);
- if (r < 0) {
+ r = sd_journal_get_data(j, "_SOURCE_REALTIME_TIMESTAMP", &data, &length);
+ if (r == -ENOENT)
+ log_debug("Source realtime timestamp not found");
+ else if (r < 0) {
log_full(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_ERR,
- "Failed to get realtime timestamp: %s", strerror(-r));
+ "Failed to get source realtime timestamp: %s", strerror(-r));
return r;
+ } else {
+ _cleanup_free_ char *value = NULL;
+ size_t size;
+
+ r = parse_field(data, length, "_SOURCE_REALTIME_TIMESTAMP=", &value, &size);
+ if (r < 0)
+ log_debug("_SOURCE_REALTIME_TIMESTAMP invalid: %s", strerror(-r));
+ else {
+ r = safe_atou64(value, &realtime);
+ if (r < 0)
+ log_debug("Failed to parse realtime timestamp: %s",
+ strerror(-r));
+ }
+ }
+
+ if (r < 0) {
+ r = sd_journal_get_realtime_usec(j, &realtime);
+ if (r < 0) {
+ log_full(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_ERR,
+ "Failed to get realtime timestamp: %s", strerror(-r));
+ return r;
+ }
}
r = sd_journal_get_cursor(j, &cursor);