summaryrefslogtreecommitdiff
path: root/src/logs-show.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-01-07 04:09:59 +0100
committerLennart Poettering <lennart@poettering.net>2012-01-07 04:10:21 +0100
commit6c1e6b98bde8288d65d7cddf87ff9bedf94a3e1c (patch)
tree1dbafbfac62dc374edccc1e5153fbb1c71e5f132 /src/logs-show.c
parentaaf53376aaac326b700fd3f8e28bbd842f0a9ed1 (diff)
journald: add kmsg source
Diffstat (limited to 'src/logs-show.c')
-rw-r--r--src/logs-show.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/logs-show.c b/src/logs-show.c
index d067ab818e..decb89b6df 100644
--- a/src/logs-show.c
+++ b/src/logs-show.c
@@ -64,6 +64,7 @@ static int parse_field(const void *data, size_t length, const char *field, char
return -ENOMEM;
}
+ free(*target);
*target = buf;
*target_size = nl;
@@ -92,8 +93,8 @@ static int output_short(sd_journal *j, unsigned line, bool show_all) {
const void *data;
size_t length;
size_t n = 0;
- char *hostname = NULL, *identifier = NULL, *comm = NULL, *pid = NULL, *message = NULL;
- size_t hostname_len = 0, identifier_len = 0, comm_len = 0, pid_len = 0, message_len = 0;
+ char *hostname = NULL, *identifier = NULL, *comm = NULL, *pid = NULL, *fake_pid = NULL, *message = NULL;
+ size_t hostname_len = 0, identifier_len = 0, comm_len = 0, pid_len = 0, fake_pid_len = 0, message_len = 0;
assert(j);
@@ -123,6 +124,12 @@ static int output_short(sd_journal *j, unsigned line, bool show_all) {
else if (r > 0)
continue;
+ r = parse_field(data, length, "SYSLOG_PID=", &fake_pid, &fake_pid_len);
+ if (r < 0)
+ goto finish;
+ else if (r > 0)
+ continue;
+
r = parse_field(data, length, "MESSAGE=", &message, &message_len);
if (r < 0)
goto finish;
@@ -164,6 +171,9 @@ static int output_short(sd_journal *j, unsigned line, bool show_all) {
if (pid && shall_print(show_all, pid, pid_len)) {
printf("[%.*s]", (int) pid_len, pid);
n += pid_len + 2;
+ } else if (fake_pid && shall_print(show_all, fake_pid, fake_pid_len)) {
+ printf("[%.*s]", (int) fake_pid_len, fake_pid);
+ n += fake_pid_len + 2;
}
if (show_all)
@@ -193,6 +203,7 @@ finish:
free(identifier);
free(comm);
free(pid);
+ free(fake_pid);
free(message);
return r;