From: Lukasz Bardeli Date: Fri, 27 Nov 2015 14:12:23 +0000 (+0100) Subject: [Power] update logs X-Git-Tag: submit/tizen_mobile/20151215.080542^2~64^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4daeef1da7da9588106b84efc9941e3b871fde6;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Power] update logs Verification] Code compiles without errors Change-Id: I89ab50bd0711388a0baf1091e0009fddc021631b Signed-off-by: Lukasz Bardeli --- diff --git a/src/power/power_instance.cc b/src/power/power_instance.cc index 5d2e1328..dc6fe901 100755 --- a/src/power/power_instance.cc +++ b/src/power/power_instance.cc @@ -88,7 +88,7 @@ enum PowerCallbacks { #define CHECK_EXIST(args, name, out) \ if (!args.contains(name)) {\ - ReportError(TypeMismatchException(name" is required argument"), out);\ + LogAndReportError(TypeMismatchException(name" is required argument"), out);\ return;\ } @@ -101,7 +101,7 @@ void PowerInstance::PowerManagerRequest(const picojson::value& args, picojson::o PowerManager::GetInstance()->Request(kPowerResourceMap.at(resource), kPowerStateMap.at(state)); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(out); } @@ -112,7 +112,7 @@ void PowerInstance::PowerManagerRelease(const picojson::value& args, picojson::o PlatformResult result = PowerManager::GetInstance()->Release(kPowerResourceMap.at(resource)); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(out); } @@ -124,7 +124,7 @@ void PowerInstance::PowerManagerGetscreenbrightness(const picojson::value& args, PlatformResult result = PowerManager::GetInstance()->GetScreenBrightness(&brightness); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(picojson::value(brightness), out); } @@ -138,7 +138,7 @@ void PowerInstance::PowerManagerSetscreenbrightness(const picojson::value& args, PlatformResult result = PowerManager::GetInstance()->SetScreenBrightness(brightness); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(out); } @@ -148,7 +148,7 @@ void PowerInstance::PowerManagerIsscreenon(const picojson::value& args, picojson bool state = false; PlatformResult result = PowerManager::GetInstance()->IsScreenOn(&state); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(picojson::value(state), out); } @@ -158,7 +158,7 @@ void PowerInstance::PowerManagerRestorescreenbrightness(const picojson::value& a PlatformResult result = PowerManager::GetInstance()->RestoreScreenBrightness(); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(out); } @@ -167,7 +167,7 @@ void PowerInstance::PowerManagerTurnscreenon(const picojson::value& args, picojs LoggerD("Enter"); PlatformResult result = PowerManager::GetInstance()->SetScreenState(true); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(out); } @@ -176,7 +176,7 @@ void PowerInstance::PowerManagerTurnscreenoff(const picojson::value& args, picoj LoggerD("Enter"); PlatformResult result = PowerManager::GetInstance()->SetScreenState(false); if (result.IsError()) - ReportError(result, &out); + LogAndReportError(result, &out); else ReportSuccess(out); } diff --git a/src/power/power_manager.cc b/src/power/power_manager.cc index 42eaccc7..865dca47 100644 --- a/src/power/power_manager.cc +++ b/src/power/power_manager.cc @@ -138,17 +138,17 @@ void PowerManager::RemoveListener(PowerManagerListener* listener) { PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { LoggerD("Enter"); if (resource == POWER_RESOURCE_SCREEN && state == POWER_STATE_CPU_AWAKE) - return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "invalid PowerState"); + return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "invalid PowerState"); if (resource == POWER_RESOURCE_CPU && state != POWER_STATE_CPU_AWAKE) - return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "invalid PowerState"); + return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "invalid PowerState"); if(current_requested_state_ == POWER_STATE_SCREEN_DIM) { int result = 0; auto error_code = PowerPlatformProxy::GetInstance().UnlockState(&result); if (!error_code || result < 0) { - LoggerE("deviceUnlockState error %d", result); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "device_power_request_unlock error"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "device_power_request_unlock error", + ("deviceUnlockState error %d", result)); } } @@ -158,9 +158,9 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { { ret = device_power_request_lock(POWER_LOCK_CPU, 0); if (DEVICE_ERROR_NONE != ret) { - LoggerE("device_power_request_lock error %d", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "device_power_request_lock error"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "device_power_request_lock error", + ("device_power_request_lock error %d", ret)); } break; } @@ -169,9 +169,9 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { int result = 0; auto error_code = PowerPlatformProxy::GetInstance().LockState(&result); if (!error_code || result < 0) { - LoggerE("device_power_request_lock error %d", result); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "device_power_request_lock error"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "device_power_request_lock error", + ("device_power_request_lock error %d", result)); } break; } @@ -179,9 +179,9 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { { ret = device_power_request_lock(POWER_LOCK_DISPLAY, 0); if (DEVICE_ERROR_NONE != ret) { - LoggerE("device_power_request_lock error %d", ret); - return PlatformResult(ErrorCode::INVALID_VALUES_ERR, - "device_power_request_lock error"); + return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, + "device_power_request_lock error", + ("device_power_request_lock error %d", ret)); } break; } @@ -190,9 +190,9 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { int max_brightness; ret = device_display_get_max_brightness(0, &max_brightness); if (DEVICE_ERROR_NONE != ret) { - LoggerE("Platform error while getting max brightness: %d", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "Platform error while getting max brightness"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "Platform error while getting max brightness", + ("Platform error while getting max brightness: %d", ret)); } PlatformResult set_result = SetPlatformBrightness(max_brightness); @@ -202,16 +202,16 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { ret = device_display_change_state(DISPLAY_STATE_NORMAL); if (DEVICE_ERROR_NONE != ret) { - LoggerE("device_display_change_state(DISPLAY_STATE_NORMAL) error %d", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "device_display_change_state error"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "device_display_change_state error", + ("device_display_change_state(DISPLAY_STATE_NORMAL) error %d", ret)); } ret = device_power_request_lock(POWER_LOCK_DISPLAY, 0); if (DEVICE_ERROR_NONE != ret) { - LoggerE("device_power_request_lock error %d", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "device_power_request_lock error"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "device_power_request_lock error", + ("device_power_request_lock error %d", ret)); } bright_state_enabled_ = true; @@ -225,11 +225,10 @@ PlatformResult PowerManager::Request(PowerResource resource, PowerState state) { break; } case POWER_STATE_SCREEN_OFF: - LoggerE("SCREEN_OFF state cannot be requested"); - return PlatformResult(ErrorCode::INVALID_VALUES_ERR, + return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "SCREEN_OFF state cannot be requested"); default: - return PlatformResult(ErrorCode::UNKNOWN_ERR, + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Platform error while locking state"); } @@ -249,9 +248,9 @@ PlatformResult PowerManager::Release(PowerResource resource) { int result = 0; auto error_code = PowerPlatformProxy::GetInstance().SetBrightnessFromSettings(&result); if (!error_code || DEVICE_ERROR_NONE != result) { - LoggerE("Platform error while setting restore brightness %d", result); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "Platform error while setting restore brightness"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "Platform error while setting restore brightness", + ("Platform error while setting restore brightness %d", result)); } } bright_state_enabled_ = false; @@ -299,9 +298,9 @@ PlatformResult PowerManager::GetScreenBrightness(double* output) { int max_brightness; int ret = device_display_get_max_brightness(0, &max_brightness); if (DEVICE_ERROR_NONE != ret) { - LoggerE("Platform error while getting brightness: %d", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "Platform error while getting max brightness"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "Platform error while getting max brightness", + ("Platform error while getting brightness: %d", ret)); } *output = (double)brightness/(double)max_brightness; return PlatformResult(ErrorCode::NO_ERROR); @@ -310,14 +309,14 @@ PlatformResult PowerManager::GetScreenBrightness(double* output) { PlatformResult PowerManager::SetScreenBrightness(double brightness) { LoggerD("Enter"); if (brightness > 1 || brightness < 0) - return PlatformResult(ErrorCode::INVALID_VALUES_ERR, + return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "brightness should be 0 <= brightness <= 1"); int max_brightness; int ret = device_display_get_max_brightness(0, &max_brightness); if (DEVICE_ERROR_NONE != ret) { - LoggerE("Platform error while setting restore brightness: %d", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "Platform error while getting max brightness"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "Platform error while getting max brightness", + ("Platform error while setting restore brightness: %d", ret)); } int platform_brightness = (int)(brightness * max_brightness); @@ -337,8 +336,8 @@ PlatformResult PowerManager::IsScreenOn(bool* state) { int ret = device_display_get_state(&platform_state); if (DEVICE_ERROR_NONE != ret) { - LoggerE("device_display_get_state failed (%d)", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while getting screen state."); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Error while getting screen state.", + ("device_display_get_state failed (%d)", ret)); } *state = (DISPLAY_STATE_SCREEN_OFF != platform_state); @@ -349,9 +348,9 @@ PlatformResult PowerManager::SetScreenState(bool onoff) { LoggerD("Enter"); int ret = device_display_change_state(onoff ? DISPLAY_STATE_NORMAL : DISPLAY_STATE_SCREEN_OFF); if (DEVICE_ERROR_NONE != ret) { - LoggerE("Platform error while changing screen state %d", ret); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "Platform error while changing screen state"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "Platform error while changing screen state", + ("Platform error while changing screen state %d", ret)); } int timeout = 100; @@ -378,9 +377,9 @@ PlatformResult PowerManager::RestoreScreenBrightness() { int result = 0; auto error_code = PowerPlatformProxy::GetInstance().SetBrightnessFromSettings(&result); if (!error_code || DEVICE_ERROR_NONE != result) { - LoggerE("Platform error while restoring brightness %d", result); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "Platform error while restoring brightness"); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "Platform error while restoring brightness", + ("Platform error while restoring brightness %d", result)); } return PlatformResult(ErrorCode::NO_ERROR); } @@ -404,9 +403,9 @@ PlatformResult PowerManager::SetPlatformBrightness(int brightness) { int result = 0; auto error_code = PowerPlatformProxy::GetInstance().SetBrightness(brightness, &result); if (!error_code || result != 0) { - LoggerE("Platform error while setting %d brightness: %d", brightness, result); - return PlatformResult(ErrorCode::UNKNOWN_ERR, - "Platform error while setting brightness."); + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, + "Platform error while setting brightness.", + ("Platform error while setting %d brightness: %d", brightness, result)); } set_custom_brightness_ = true; current_brightness_ = brightness;