dump_systemstate : add journal log 71/153071/3 accepted/tizen/unified/20170928.072303 submit/tizen/20170928.020903
authorKichan Kwon <k_c.kwon@samsung.com>
Thu, 28 Sep 2017 01:46:21 +0000 (10:46 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Thu, 28 Sep 2017 02:06:06 +0000 (11:06 +0900)
- Log only latest 1024 logs from last boot

Change-Id: I535402a6807d2c4a21fb08a2ba874473f49045f6
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
src/crash-manager/crash-manager.c
src/dump_systemstate/dump_systemstate.c
src/log_dump/log_dump.c

index 1d91d3a..24f48bf 100644 (file)
@@ -439,7 +439,7 @@ static int dump_system_state(void)
        char command[PATH_MAX];
 
        ret = snprintf(command, sizeof(command),
-                       "/usr/bin/dump_systemstate -d -k -f %s",
+                       "/usr/bin/dump_systemstate -d -k -j -f %s",
                        crash_info.log_path);
        if (ret < 0) {
                _E("Failed to snprintf for dump_systemstate command");
index 673ca9a..09467b1 100644 (file)
@@ -59,6 +59,7 @@ static void usage()
                        "  -f: write to file (instead of stdout)\n"
                        "  -k: dump kernel messages (only root)\n"
                        "  -d: dump dlog messages\n"
+                       "  -j: dump journal log messages\n"
           );
 }
 
@@ -85,12 +86,13 @@ int main(int argc, char *argv[])
        int out_fd = -1;
        bool arg_dlog = false;
        bool arg_dmesg = false;
+       bool arg_journal = false;
        char timestr[80];
        time_t cur_time;
        struct tm gm_tm;
        struct tm loc_tm;
 
-       while ((c = getopt(argc, argv, "hf:kd")) != -1) {
+       while ((c = getopt(argc, argv, "hf:kdj")) != -1) {
                switch (c) {
                case 'd':
                        arg_dlog = true;
@@ -98,6 +100,9 @@ int main(int argc, char *argv[])
                case 'k':
                        arg_dmesg = true;
                        break;
+               case 'j':
+                       arg_journal = true;
+                       break;
                case 'f':
                        arg_file = optarg;
                        break;
@@ -201,6 +206,13 @@ int main(int argc, char *argv[])
                        goto exit_close;
        }
 
+       if (arg_journal) {
+               fprintf_fd(out_fd, "\n==== Journal messages\n");
+               ret = run_command_write_fd("/usr/bin/journalctl -b -n 1024", out_fd);
+               if (ret < 0)
+                       goto exit_close;
+       }
+
 exit_close:
        if (arg_file)
                close(out_fd);
index 16150a9..5ea5095 100644 (file)
@@ -60,7 +60,7 @@ static int dump_scripts(void)
 
        script_num = scandir(DUMP_SCRIPTS_DIR, &dir_list, NULL, NULL);
        if (script_num < 0) {
-               _E("Failed to scandir %s",DUMP_SCRIPTS_DIR);
+               _E("Failed to scandir %s", DUMP_SCRIPTS_DIR);
                return -1;
        }
 
@@ -133,7 +133,7 @@ int log_dump(int option)
 
        /* Dump system states */
        ret = snprintf(command, sizeof(command),
-                       "/usr/bin/dump_systemstate -k -d -f "
+                       "/usr/bin/dump_systemstate -k -d -j -f "
                        "%s/dump_systemstate_%s.log", LOG_DUMP_DIR, timestr);
        if (ret < 0) {
                _E("Failed to snprintf for command");