From: Kichan Kwon Date: Fri, 10 Jun 2016 03:15:58 +0000 (+0900) Subject: dlogutil : add "-d" option when the backend is journal X-Git-Tag: accepted/tizen/common/20160616.151640^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F73892%2F3;p=platform%2Fcore%2Fsystem%2Fdlog.git dlogutil : add "-d" option when the backend is journal - "-d" : print log and exit (non-blocking) - "-v" is ignored because of crash-worker issue Change-Id: I81ae7854b1f9bbbc5e107a198f880b2ef577103f Signed-off-by: Kichan Kwon --- diff --git a/src/logutil/logutil_journal.c b/src/logutil/logutil_journal.c index 0def4e2..4cb4d6a 100755 --- a/src/logutil/logutil_journal.c +++ b/src/logutil/logutil_journal.c @@ -17,6 +17,7 @@ #include #include +#include #include "dlog.h" @@ -26,6 +27,7 @@ int main (int argc, char **argv) { int r; sd_journal *j; + int no_wait = 0; static const char pri_table[DLOG_PRIO_MAX] = { [LOG_DEBUG] = 'D', @@ -42,6 +44,28 @@ int main (int argc, char **argv) return 1; } + for (;;) { + int ret; + + ret = getopt(argc, argv, "dv:"); + + if (ret < 0) + break; + + switch (ret) { + case 'd': + no_wait = 1; + break; + /* Ignore this option */ + case 'v': + break; + default: + printf("Unrecognized Option\n"); + exit(-1); + break; + }; + } + fprintf(stderr, "read\n"); SD_JOURNAL_FOREACH(j) { const char *priority, *log_tag, *tid, *message; @@ -73,6 +97,11 @@ int main (int argc, char **argv) fprintf(stdout, "%c/%s(%5d): %s\n", pri_table[prio_idx], log_tag+8, atoi(tid+4), message+8); } + if (no_wait) { + sd_journal_close(j); + return 0; + } + fprintf(stderr, "wait\n"); for (;;) { const char *log_tag, *priority, *tid, *message;