From: Alice Liu Date: Wed, 27 Aug 2014 10:44:39 +0000 (+0800) Subject: SDB: Added journal log support for 'sdb dlog' X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab02751fbd426269a408c391d5190bdac4042eda;p=sdk%2Ftools%2Fsdb.git SDB: Added journal log support for 'sdb dlog' In Tizen 3, it started to use journalctl command instead of dlogutil command to check log. This patch will determine whether journalctl binary exists in the system. If it does, 'sdb dlog' will call journalctl, or else it will call dlogutil. Change-Id: Ic1eec3259e7f489fe6bd1dc2f23914bc9e9830d4 Signed-off-by: Alice Liu --- diff --git a/src/command_function.c b/src/command_function.c index abd3c57..884f4c9 100644 --- a/src/command_function.c +++ b/src/command_function.c @@ -52,6 +52,7 @@ static int get_pkgtype_file_name(const char* file_name); static int get_pkgtype_from_app_id(const char* app_id); static int kill_gdbserver_if_running(const char* process_cmd); static int verify_gdbserver_exist(); +static int verify_journalctl_exist(); static int get_pkg_tmp_dir(char* pkg_tmp_dir); int da(int argc, char ** argv) { @@ -494,7 +495,12 @@ int forward_remove_all() { int dlog(int argc, char ** argv) { D("dlog with serial: %s\n", target_serial); - char full_cmd[PATH_MAX] = "shell:/usr/bin/dlogutil"; + char full_cmd[PATH_MAX]; + if (verify_journalctl_exist() < 0) { + snprintf(full_cmd, sizeof full_cmd, "shell:/usr/bin/dlogutil"); + } else { + snprintf(full_cmd, sizeof full_cmd, "shell:/usr/bin/journalctl"); + } int i; for(i = 1; i/dev/null"); + int result = sdb_connect(cmd); + + if(result < 0) { + sdb_close(result); + return -1; + } + if (read_line(result, buf, sizeof(buf)) > 0) { + print_error(SDB_MESSAGE_ERROR, buf, NULL); + sdb_close(result); + return -1; + } + sdb_close(result); + return result; +}