From: Konrad Kuchciak Date: Fri, 8 Nov 2019 10:12:24 +0000 (+0100) Subject: Change logging backend to dlog X-Git-Tag: submit/tizen/20191121.124127~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35330375c96e8101a86c19e80db5fd4096206a0e;p=platform%2Fcore%2Fsystem%2Fstability-monitor.git Change logging backend to dlog Change-Id: Ifa858cbbd67082611704f0109a1c6ba00a26ba7f --- diff --git a/packaging/stability-monitor.spec b/packaging/stability-monitor.spec index 34d39ba..cc09f99 100644 --- a/packaging/stability-monitor.spec +++ b/packaging/stability-monitor.spec @@ -14,6 +14,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(crash-service) +BuildRequires: pkgconfig(dlog) ExclusiveArch: armv7l Requires: %{KMOD_PATH} diff --git a/src/action.c b/src/action.c index 4a220c6..f5b2a02 100644 --- a/src/action.c +++ b/src/action.c @@ -98,7 +98,7 @@ skip_dbus_signal: /* Kill the process */ if (ad->ds->process->kill) { - _D_PROC(ad->ds->process, "Killing process"); + _I_PROC(ad->ds->process, "Killing process"); if (kill(ad->ds->process->pid, SIGKILL)) _E("Unable to kill process %s(%d): %m", ad->ds->process->name, @@ -109,7 +109,7 @@ skip_dbus_signal: if (signal_params) { dbus_send_signal(objpath, interface, "AbnormalityDetected", signal_params); - _D_PROC(ad->ds->process, "Sent D-Bus signal (%s, %s)", + _I_PROC(ad->ds->process, "Sent D-Bus signal (%s, %s)", limit_type_to_string(ad->lt), ad->ds->param_name); } else { @@ -184,7 +184,7 @@ static void on_livedump_complete(GObject *gobject, _E("livedump_pid() failed (for more info please check 'dlogutil LIBCRASH-SERVICE' and/or 'dlogutil CRASH_MANAGER'"); ad->report_path[0] = 0; } else { - _D_PROC(ad->ds->process, "Received report: %s", ad->report_path); + _I_PROC(ad->ds->process, "Received report: %s", ad->report_path); } action_finish(ad); @@ -199,7 +199,7 @@ int action_run_default(struct data_source *ds, enum limit_type lt) return 0; ds->action_in_progress = 1; - _D_PROC(ds->process, "Running default action"); + _I_PROC(ds->process, "Running default action"); ad = calloc(1, sizeof(*ad)); if (!ad) { diff --git a/src/aul.c b/src/aul.c index 7de64b3..0ca773c 100644 --- a/src/aul.c +++ b/src/aul.c @@ -57,7 +57,7 @@ static void app_status_change_handler(GDBusConnection *connection, return; if (process->class != old_class) - _D_PROC(process, "Class changed"); + _I_PROC(process, "Class changed"); } else { _W("Received AUL status update for PID %d, but it wasn't found in internal state - ignoring.", pid); diff --git a/src/config.c b/src/config.c index 93ca0d0..583616e 100644 --- a/src/config.c +++ b/src/config.c @@ -47,7 +47,7 @@ int config_load(const char *config_file) if (!config) return -EINVAL; - _D("Loaded config %s\n", config_file); + _D("Loaded config %s", config_file); return 0; } @@ -71,7 +71,7 @@ static int config_load_merge(const char *config_file) } } - _D("Loaded config %s\n", config_file); + _D("Loaded config %s", config_file); return 0; } diff --git a/src/data_source.c b/src/data_source.c index 180bc5a..8516382 100644 --- a/src/data_source.c +++ b/src/data_source.c @@ -101,7 +101,7 @@ int data_source_register(struct data_source_mod *mod) } data_sources[data_sources_n++] = mod; - _D("Registered data source: %s\n", mod->name); + _I("Registered data source: %s", mod->name); return 0; diff --git a/src/data_sources/tsm_cpu.c b/src/data_sources/tsm_cpu.c index 2e866fa..3d972eb 100644 --- a/src/data_sources/tsm_cpu.c +++ b/src/data_sources/tsm_cpu.c @@ -63,7 +63,7 @@ static int update(struct data_source *ds, } if (ced->cpu_time < ced->cpu_time_last) { - _D_PROC(ds->process, "cpu_time < cpu_time_last, ignoring sample"); + _I_PROC(ds->process, "cpu_time < cpu_time_last, ignoring sample"); return 0; } diff --git a/src/data_sources/tsm_io.c b/src/data_sources/tsm_io.c index 1f80786..f2e5819 100644 --- a/src/data_sources/tsm_io.c +++ b/src/data_sources/tsm_io.c @@ -59,7 +59,7 @@ static int update(struct data_source *ds, } if (ied->io_bytes < ied->io_bytes_last) { - _D_PROC(ds->process, "io_bytes < io_bytes_last, ignoring sample"); + _I_PROC(ds->process, "io_bytes < io_bytes_last, ignoring sample"); return 0; } diff --git a/src/dbus.c b/src/dbus.c index 4eb0036..dadda70 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -69,12 +69,12 @@ int dbus_send_signal(const char *object_path, goto cleanup; } - _DD("Emitted signal\n" - " objpath: %s\n" - " interface: %s\n" - " member: %s\n" - " parameters: %s\n", - object_path, interface_name, signal_name, parameters_str); + _D("Emitted signal\n" + " objpath: %s\n" + " interface: %s\n" + " member: %s\n" + " parameters: %s\n", + object_path, interface_name, signal_name, parameters_str); cleanup: g_free(parameters_str); diff --git a/src/log.h b/src/log.h index 016245b..9d74fa9 100644 --- a/src/log.h +++ b/src/log.h @@ -20,32 +20,35 @@ #define LOG_H #include +#include #include "utils.h" #include "process.h" -#define print(fmt, arg...) \ - printf(fmt, ##arg); \ +#define TAG "STABILITY_MONITOR" + +#define print(lvl, fmt, arg...) \ + dlog_print(lvl, TAG, fmt, ##arg); \ log_inc_msg_count() -#define _E(fmt, arg...) do { \ - print("ERROR: %s::%s(%d): " fmt "\n", __FILE__, __FUNCTION__, __LINE__, ##arg); \ +#define _E(fmt, arg...) do { \ + print(DLOG_ERROR, "%s::%s(%d): " fmt, __FILE__, __FUNCTION__, __LINE__, ##arg); \ } while (0) -#define _W(fmt, arg...) do { \ - print("WARN: %s::%s(%d): " fmt "\n", __FILE__, __FUNCTION__, __LINE__, ##arg); \ +#define _W(fmt, arg...) do { \ + print(DLOG_WARN, "%s::%s(%d): " fmt, __FILE__, __FUNCTION__, __LINE__, ##arg); \ } while (0) -#define _D(fmt, arg...) do { \ - print(fmt, ##arg); \ +#define _I(fmt, arg...) do { \ + print(DLOG_INFO, fmt, ##arg); \ } while (0) -#define _DD(fmt, arg...) do { \ - /* TODO */ \ +#define _D(fmt, arg...) do { \ + print(DLOG_DEBUG, fmt, ##arg); \ } while (0) -#define _D_PROC(process, fmt, arg...) \ - _D("(%d)\t[%-25.25s | %-21s ] " fmt "\n", \ +#define _I_PROC(process, fmt, arg...) \ + _I("(%d)\t[%-25.25s | %-21s ] " fmt, \ process->pid, \ process->name, \ process_class_to_string(process->class), \ diff --git a/src/process.c b/src/process.c index 212307e..7b419c1 100644 --- a/src/process.c +++ b/src/process.c @@ -120,7 +120,7 @@ int process_create_info(int pid, int ppid, struct proc_info **process) process_ref(p); if (p->monitor) - _D_PROC(p, "Created process"); + _I_PROC(p, "Created process"); return 0; } @@ -409,7 +409,7 @@ void process_check_limits(struct proc_info *process) /* Peak limit */ if (sample_is_greater(last_sample, &ds->limit.peak)) { - _D_PROC(process, "%s: PEAK limit exceeded (%s)", + _I_PROC(process, "%s: PEAK limit exceeded (%s)", ds->name, smpl2str(last_sample)); ds->action(ds, LIMIT_TYPE_PEAK); @@ -417,7 +417,7 @@ void process_check_limits(struct proc_info *process) /* Avg limit */ if (sc->average > ds->limit.avg) { - _D_PROC(process, "%s: AVG limit exceeded (%2.3lf)", + _I_PROC(process, "%s: AVG limit exceeded (%2.3lf)", ds->name, sc->average); ds->action(ds, LIMIT_TYPE_AVG); @@ -443,7 +443,7 @@ static void _print_header(struct proc_info *process) for (int i = 0; i < header_lines; i++) { header_items[(ds_n + 1) * i + ds_n] = NULL; str = g_strjoinv(NULL, &header_items[(ds_n + 1) * i]); - _D_PROC(process, "%s", str); + _I_PROC(process, "%s", str); g_free(str); } @@ -485,7 +485,7 @@ void process_print_current_state(struct proc_info *process) state_items[ds_n] = NULL; state_msg = g_strjoinv(NULL, state_items); - _D_PROC(process, "%s", state_msg); + _I_PROC(process, "%s", state_msg); g_strfreev(state_items); g_free(state_msg); @@ -559,7 +559,7 @@ void process_unref(struct proc_info *process) { process->ref_count--; if (process->ref_count <= 0) { if (process->monitor) - _D_PROC(process, "Removing process"); + _I_PROC(process, "Removing process"); process_cleanup(process); } } diff --git a/src/raw_data.c b/src/raw_data.c index 9e8d455..b2df372 100644 --- a/src/raw_data.c +++ b/src/raw_data.c @@ -54,7 +54,7 @@ int raw_data_provider_register(struct raw_data_provider *mod) /* TODO: Check name */ rdp = mod; - _D("Registered raw data provider: %s\n", mod->name); + _I("Registered raw data provider: %s", mod->name); return 0; } diff --git a/src/raw_data_providers/proc_tsm.c b/src/raw_data_providers/proc_tsm.c index 7898522..96ff3fe 100644 --- a/src/raw_data_providers/proc_tsm.c +++ b/src/raw_data_providers/proc_tsm.c @@ -72,7 +72,7 @@ static int get_raw_data(struct list_head *rd) ret = str_to_ullarray(buf, rd_i->v); if (ret <= 0) { - _E("Unable to parse raw data from kernel: \"%s\"\n", buf); + _E("Unable to parse raw data from kernel: \"%s\"", buf); goto error; } } @@ -94,7 +94,7 @@ static int init(void) int fd, ret = 0; if (access(PROC_TSM_PATH, O_RDONLY) == 0) { - _D("Kernel module already loaded\n"); + _I("Kernel module already loaded"); return 0; } diff --git a/src/sample.c b/src/sample.c index f4a9213..0b0b45e 100644 --- a/src/sample.c +++ b/src/sample.c @@ -89,7 +89,7 @@ void sample_print_list(struct list_head *list) struct sample_s *sample; list_for_each_entry(sample, list, node) { - _D("sample %p\n", sample); + _I("sample %p", sample); } } diff --git a/src/stability-monitor.c b/src/stability-monitor.c index cb19625..cfebe34 100644 --- a/src/stability-monitor.c +++ b/src/stability-monitor.c @@ -102,7 +102,7 @@ static int load_config(void) static gboolean signal_handler(GMainLoop *loop, const char *sig_name) { - _D("\nReceived %s, exit\n", sig_name); + _I("\nReceived %s, exit", sig_name); g_main_loop_quit(loop); return FALSE; } @@ -178,7 +178,7 @@ static gboolean run(gpointer data) ret = process_create_info(rd_i->v[0], rd_i->v[1], &process); if (ret) { if (ret == -EEXIST) - _DD("Unable to create process info, it has just died\n"); + _D("Unable to create process info, it has just died\n"); else _E("Unable to create process info: %d", ret); @@ -221,7 +221,7 @@ static gboolean run(gpointer data) cleanup: raw_data_cleanup(&rd); - // _D("Run took %lf s\n", (double) 1. * (time_now() - _t) / USEC_PER_SEC); + // _D("Run took %lf s", (double) 1. * (time_now() - _t) / USEC_PER_SEC); return TRUE; } diff --git a/src/utils.c b/src/utils.c index 44c49bc..194eeb0 100644 --- a/src/utils.c +++ b/src/utils.c @@ -62,7 +62,7 @@ int pid_to_basename(int pid, char *basename, size_t basename_buflen) * which readlink never appends on its own) */ ret = readlink(link_name, path, sizeof(path) - 1); if (ret <= 0) { - _DD("readlink() failed, pid: %d, ret: %d\n", pid, ret); + _D("readlink() failed, pid: %d, %m", pid); return -EEXIST; }