Change logging backend to dlog 35/217335/1
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Fri, 8 Nov 2019 10:12:24 +0000 (11:12 +0100)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Fri, 8 Nov 2019 10:12:24 +0000 (11:12 +0100)
Change-Id: Ifa858cbbd67082611704f0109a1c6ba00a26ba7f

15 files changed:
packaging/stability-monitor.spec
src/action.c
src/aul.c
src/config.c
src/data_source.c
src/data_sources/tsm_cpu.c
src/data_sources/tsm_io.c
src/dbus.c
src/log.h
src/process.c
src/raw_data.c
src/raw_data_providers/proc_tsm.c
src/sample.c
src/stability-monitor.c
src/utils.c

index 34d39ba..cc09f99 100644 (file)
@@ -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}
 
index 4a220c6..f5b2a02 100644 (file)
@@ -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) {
index 7de64b3..0ca773c 100644 (file)
--- 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);
index 93ca0d0..583616e 100644 (file)
@@ -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;
 }
index 180bc5a..8516382 100644 (file)
@@ -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;
 
index 2e866fa..3d972eb 100644 (file)
@@ -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;
     }
 
index 1f80786..f2e5819 100644 (file)
@@ -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;
     }
 
index 4eb0036..dadda70 100644 (file)
@@ -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);
index 016245b..9d74fa9 100644 (file)
--- a/src/log.h
+++ b/src/log.h
 #define LOG_H
 
 #include <stdio.h>
+#include <dlog.h>
 
 #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), \
index 212307e..7b419c1 100644 (file)
@@ -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);
     }
 }
index 9e8d455..b2df372 100644 (file)
@@ -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;
 }
index 7898522..96ff3fe 100644 (file)
@@ -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;
     }
 
index f4a9213..0b0b45e 100644 (file)
@@ -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);
     }
 }
 
index cb19625..cfebe34 100644 (file)
@@ -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;
 }
 
index 44c49bc..194eeb0 100644 (file)
@@ -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;
     }