Introduce critical-log API from dlog 87/225087/4
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 17 Feb 2020 08:14:58 +0000 (17:14 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 18 Feb 2020 04:11:23 +0000 (04:11 +0000)
Below are added as critical-log
- Power(Display) lock/unlock
- PowerOff/Reboot
- Battery status/health

Change-Id: I6f2f5b1ee660d4f6a8a426b71d311719f9304a36
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/iot/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/battery/lowbat-handler.c
src/battery/power-supply.c
src/core/main.c
src/power/boot.c
src/power/power-handler.c
src/shared/log-macro.h

index ea376e6..c75b0d5 100644 (file)
@@ -1459,7 +1459,7 @@ static void proc_condition_lock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(true, pid);
 
-       _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
+       CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type = PM_LCDOFF_STR;
@@ -1511,7 +1511,7 @@ static void proc_condition_unlock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(false, pid);
 
-       _I("[%s] unlocked by %5d", states[state].name, pid);
+       CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type = PM_LCDOFF_STR;
index 8a5b71c..224c0b9 100644 (file)
@@ -1469,7 +1469,7 @@ static void proc_condition_lock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(true, pid);
 
-       _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
+       CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type = PM_LCDOFF_STR;
@@ -1521,7 +1521,7 @@ static void proc_condition_unlock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(false, pid);
 
-       _I("[%s] unlocked by %5d", states[state].name, pid);
+       CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type =  PM_LCDOFF_STR;
index fc02a25..ecb23ab 100644 (file)
@@ -1456,7 +1456,7 @@ static void proc_condition_lock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(true, pid);
 
-       _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
+       CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type = PM_LCDOFF_STR;
@@ -1508,7 +1508,7 @@ static void proc_condition_unlock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(false, pid);
 
-       _I("[%s] unlocked by %5d", states[state].name, pid);
+       CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type = PM_LCDOFF_STR;
index 9627b9e..b5bcc18 100644 (file)
@@ -1479,7 +1479,7 @@ static void proc_condition_lock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(true, pid);
 
-       _I("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
+       CRITICAL_LOG("[%s] locked by %5d with %u ms", states[state].name, pid, data->timeout);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type = PM_LCDOFF_STR;
@@ -1531,7 +1531,7 @@ static void proc_condition_unlock(PMMsg *data)
        if (state == S_LCDOFF)
                set_process_active(false, pid);
 
-       _I("[%s] unlocked by %5d", states[state].name, pid);
+       CRITICAL_LOG("[%s] unlocked by %5d", states[state].name, pid);
        /* for debug */
        if (state == S_LCDOFF)
                lock_type = PM_LCDOFF_STR;
index 4a2934b..670d2b2 100644 (file)
@@ -432,6 +432,7 @@ static int battery_critical_low_act(void *data)
 
 int battery_power_off_act(void *data)
 {
+       CRITICAL_LOG("Low battery power off.");
        return power_execute(POWER_POWEROFF);
 }
 
@@ -587,6 +588,7 @@ static void battery_level_send_system_event(int bat_percent)
        prev = str;
 
        _D("System_event: %s", str);
+       CRITICAL_LOG("Battery %s.", str);
        event_system_send(SYS_EVENT_BATTERY_LEVEL_STATUS,
                        EVT_KEY_BATTERY_LEVEL_STATUS, str);
 }
index 0932597..4e8bbcf 100644 (file)
@@ -199,7 +199,7 @@ static gboolean health_timer_cb(void *data)
        if (battery.health != HEALTH_LOW && battery.health != HEALTH_HIGH)
                return G_SOURCE_REMOVE;
 
-       _I("Popup: Battery health status is not good.");
+       CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery.health_s);
        device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health);
        battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
        if (disp_plgn.pm_unlock_internal)
@@ -472,14 +472,19 @@ static void charger_state_send_system_event(int state)
                str = EVT_VAL_BATTERY_CHARGER_CHARGING;
                break;
        case CHARGE_STATUS_FULL:
+               str = EVT_VAL_BATTERY_CHARGER_DISCHARGING;
+               CRITICAL_LOG("Battery %s", str);
+               break;
        case CHARGE_STATUS_DISCHARGING:
                str = EVT_VAL_BATTERY_CHARGER_DISCHARGING;
                break;
        case CHARGE_STATUS_CONNECTED:
                str = EVT_VAL_BATTERY_CHARGER_CONNECTED;
+               CRITICAL_LOG("Battery %s", str);
                break;
        case CHARGE_STATUS_DISCONNECTED:
                str = EVT_VAL_BATTERY_CHARGER_DISCONNECTED;
+               CRITICAL_LOG("Battery %s", str);
                break;
        default:
                _E("Invalid parameter: %d", state);
@@ -501,7 +506,7 @@ int changed_battery_cf(int status)
 static void update_present(enum battery_noti_status status)
 {
 
-       _I("Charge(%d) present(%d)", battery.charge_now, battery.present);
+       CRITICAL_LOG("Charge(%d) present(%d)", battery.charge_now, battery.present);
 
        if (status == DEVICE_NOTI_ON) {
                battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
@@ -529,9 +534,9 @@ void remove_health_popup(void)
 static void update_health(enum battery_noti_status status)
 {
        _I("Charge(%d) health(%d)", battery.charge_now, battery.health);
+       CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery.health_s);
 
        if (status == DEVICE_NOTI_ON) {
-               _I("Popup: Battery health status is not good.");
                battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
                if (disp_plgn.pm_change_internal)
                        disp_plgn.pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
@@ -1148,6 +1153,8 @@ static GVariant *dbus_charger_charging(GDBusConnection *conn,
        if (ret == 0 && val != chg_on) {
                battery.charger_charging = val;
                ret = sys_set_int(CHARGER_CHARGE_ON_NODE, battery.charger_charging);
+               CRITICAL_LOG("chg_on changed to %d %s", battery.charger_charging,
+                       (ret == 0) ? "success" : "fail");
                _I("%s to change status with %d.", ((ret == 0) ? "success" : "fail"), battery.charger_charging);
        } else {
                _I("Skip change status with %d (ret %d prev %d)", val, ret, battery.charger_charging);
@@ -1476,7 +1483,7 @@ static void change_health_popup_timer(enum battery_noti_status status)
 
 static void launch_health_popup(void)
 {
-       _I("Popup - Health is not good(health %s)", (battery.health == HEALTH_HIGH) ? "TempHigh" : "TempLow");
+       CRITICAL_LOG("Popup: Battery health status is not good, %s.", battery.health_s);
        health_popup_timer_init(__func__);
        device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health);
        battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
index 5c80542..ac24e73 100644 (file)
@@ -57,7 +57,7 @@ static void sig_quit(int signo)
 
 static void sig_usr1(int signo)
 {
-       _D("Received SIGUSR1 signal(%d), deviced'll be finished.", signo);
+       CRITICAL_LOG("Received SIGUSR1 signal(%d), deviced'll be finished.", signo);
        if (mainloop && g_main_loop_is_running(mainloop))
                g_main_loop_quit(mainloop);
 }
@@ -92,6 +92,7 @@ static int deviced_main(int argc, char **argv)
        int ret;
        dbus_handle_h handle = NULL;
 
+       CRITICAL_LOG("Initializing deviced.");
        mainloop = g_main_loop_new(NULL, FALSE);
 
        ret = check_power_flag();
@@ -123,6 +124,7 @@ static int deviced_main(int argc, char **argv)
        g_timeout_add_seconds_full(G_PRIORITY_HIGH, WATCHDOG_TIMEOUT, watchdog_cb, NULL, NULL);
 
        /* g_main_loop */
+       CRITICAL_LOG("Starting deviced.");
        g_main_loop_run(mainloop);
        g_main_loop_unref(mainloop);
 
index 3302b77..77b04bc 100644 (file)
@@ -61,7 +61,7 @@ static void booting_done_received(GDBusConnection  *conn,
                        _E("System session is not ready yet.");
                        return;
                }
-               _I("System session is ready.");
+               CRITICAL_LOG("System session is ready.");
                device_notify_once(DEVICE_NOTIFIER_BOOTING_DONE, &system_done);
 
        } else if (strcmp(name, SYSTEMD_DBUS_SIGNAL_USER_STARTUP_FINISHED) == 0) {
index 52caa68..d67103e 100644 (file)
@@ -174,7 +174,6 @@ static bool disable_coredump_handler(void)
 
 static void poweroff_request_shutdown(void)
 {
-       _I("Requested power off via systemd.");
 
        const char *method;
 
@@ -189,6 +188,7 @@ static void poweroff_request_shutdown(void)
                return;
        }
 
+       CRITICAL_LOG("Requested %s via systemd.", method);
        dbus_handle_method_sync_timeout(SYSTEMD_DBUS_DEST,
                                        SYSTEMD_DBUS_PATH,
                                        SYSTEMD_DBUS_IFACE_MANAGER,
@@ -204,11 +204,17 @@ void poweroff_prepare(void)
 {
        int off = poweroff_opt.type;
 
+       if (off == POWEROFF_TYPE_POWEROFF)
+               CRITICAL_LOG("Prepare PowerOff.");
+       else if (off == POWEROFF_TYPE_REBOOT)
+               CRITICAL_LOG("Prepare Reboot.");
+
        poweroff_notify_resourced();
        disable_systemd_journald();
        disable_coredump_handler();
 
        disable_display();
+
        device_notify(DEVICE_NOTIFIER_POWEROFF, &off);
 }
 
@@ -544,7 +550,7 @@ static GVariant *dbus_power_handler(GDBusConnection *conn,
        if (ret < 0)
                goto out;
 
-       _I("Poweroff PID(%d) requests %s.", ret, type_str);
+       CRITICAL_LOG("Poweroff PID(%d) requests %s.", ret, type_str);
        ret = power_execute_pid(type_str, NULL);
 
 out:
@@ -565,7 +571,7 @@ static GVariant *dbus_power_option_handler(GDBusConnection *conn,
        if (ret < 0)
                goto out;
 
-       _I("Poweroff PID(%d) requests type=%s option=%s.", ret, type, option);
+       CRITICAL_LOG("Poweroff PID(%d) requests type=%s option=%s.", ret, type, option);
        ret = power_execute_pid(type, option);
 
 out:
@@ -595,7 +601,7 @@ static GVariant *add_poweroff_time(GDBusConnection *conn,
 
        pid = (pid_t)ret;
 
-       _D("add_poweroff_timer pid=%d", pid);
+       CRITICAL_LOG("PID %d request poweroff timer.", pid);
 
        DD_LIST_FOREACH(poweroff_handles, l, handle) {
                if (handle->pid == pid)
index cb309af..773ea44 100644 (file)
 
 #ifdef ENABLE_DLOG
 #include <dlog.h>
+/* critical log */
+#define CRITICAL_LOG(fmt, arg...) \
+       do { CRITICAL_LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, fmt, ##arg); } while (0)
+
 #define _D(fmt, arg...) \
        do { SLOGD(fmt, ##arg); } while (0)
 #define _I(fmt, arg...) \