137a09cd7Sopenharmony_ci/* 237a09cd7Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 337a09cd7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 437a09cd7Sopenharmony_ci * you may not use this file except in compliance with the License. 537a09cd7Sopenharmony_ci * You may obtain a copy of the License at 637a09cd7Sopenharmony_ci * 737a09cd7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 837a09cd7Sopenharmony_ci * 937a09cd7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1037a09cd7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1137a09cd7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1237a09cd7Sopenharmony_ci * See the License for the specific language governing permissions and 1337a09cd7Sopenharmony_ci * limitations under the License. 1437a09cd7Sopenharmony_ci */ 1537a09cd7Sopenharmony_ci 1637a09cd7Sopenharmony_ci#ifndef THERMAL_LOG_H 1737a09cd7Sopenharmony_ci#define THERMAL_LOG_H 1837a09cd7Sopenharmony_ci 1937a09cd7Sopenharmony_ci#define CONFIG_HILOG 2037a09cd7Sopenharmony_ci#ifdef CONFIG_HILOG 2137a09cd7Sopenharmony_ci#include "hilog/log.h" 2237a09cd7Sopenharmony_cinamespace OHOS { 2337a09cd7Sopenharmony_cinamespace PowerMgr { 2437a09cd7Sopenharmony_ci 2537a09cd7Sopenharmony_ci#ifdef THERMAL_HILOGF 2637a09cd7Sopenharmony_ci#undef THERMAL_HILOGF 2737a09cd7Sopenharmony_ci#endif 2837a09cd7Sopenharmony_ci 2937a09cd7Sopenharmony_ci#ifdef THERMAL_HILOGE 3037a09cd7Sopenharmony_ci#undef THERMAL_HILOGE 3137a09cd7Sopenharmony_ci#endif 3237a09cd7Sopenharmony_ci 3337a09cd7Sopenharmony_ci#ifdef THERMAL_HILOGW 3437a09cd7Sopenharmony_ci#undef THERMAL_HILOGW 3537a09cd7Sopenharmony_ci#endif 3637a09cd7Sopenharmony_ci 3737a09cd7Sopenharmony_ci#ifdef THERMAL_HILOGI 3837a09cd7Sopenharmony_ci#undef THERMAL_HILOGI 3937a09cd7Sopenharmony_ci#endif 4037a09cd7Sopenharmony_ci 4137a09cd7Sopenharmony_ci#ifdef THERMAL_HILOGD 4237a09cd7Sopenharmony_ci#undef THERMAL_HILOGD 4337a09cd7Sopenharmony_ci#endif 4437a09cd7Sopenharmony_ci 4537a09cd7Sopenharmony_cinamespace { 4637a09cd7Sopenharmony_ci// Thermal manager reserved domain id range 4737a09cd7Sopenharmony_ciconstexpr unsigned int THERMAL_DOMAIN_ID_START = 0xD002940; 4837a09cd7Sopenharmony_ciconstexpr unsigned int THERMAL_DOMAIN_ID_END = THERMAL_DOMAIN_ID_START + 32; 4937a09cd7Sopenharmony_ciconstexpr unsigned int TEST_DOMAIN_ID = 0xD000F00; 5037a09cd7Sopenharmony_ci} 5137a09cd7Sopenharmony_ci 5237a09cd7Sopenharmony_cienum ThermalManagerLogLabel { 5337a09cd7Sopenharmony_ci // Component labels, you can add if needed 5437a09cd7Sopenharmony_ci COMP_APP = 0, 5537a09cd7Sopenharmony_ci COMP_FWK = 1, 5637a09cd7Sopenharmony_ci COMP_SVC = 2, 5737a09cd7Sopenharmony_ci COMP_HDI = 3, 5837a09cd7Sopenharmony_ci COMP_DRV = 4, 5937a09cd7Sopenharmony_ci // Feature labels, use to mark major features 6037a09cd7Sopenharmony_ci FEATURE_PROTECTOR, 6137a09cd7Sopenharmony_ci // Test label 6237a09cd7Sopenharmony_ci LABEL_TEST, 6337a09cd7Sopenharmony_ci // The end of labels, max to the domain id range length 32 6437a09cd7Sopenharmony_ci LABEL_END, 6537a09cd7Sopenharmony_ci}; 6637a09cd7Sopenharmony_ci 6737a09cd7Sopenharmony_cienum ThermalManagerLogDomain { 6837a09cd7Sopenharmony_ci DOMAIN_APP = THERMAL_DOMAIN_ID_START + COMP_APP, // 0xD002940 6937a09cd7Sopenharmony_ci DOMAIN_FRAMEWORK, // 0xD002941 7037a09cd7Sopenharmony_ci DOMAIN_SERVICE, // 0xD002942 7137a09cd7Sopenharmony_ci DOMAIN_HDI, // 0xD002943 7237a09cd7Sopenharmony_ci DOMAIN_DRIVER, // 0xD002944 7337a09cd7Sopenharmony_ci DOMAIN_FEATURE_PROTECTOR, 7437a09cd7Sopenharmony_ci DOMAIN_TEST = TEST_DOMAIN_ID, // 0xD000F00 7537a09cd7Sopenharmony_ci DOMAIN_END = THERMAL_DOMAIN_ID_END, // Max to 0xD002960, keep the sequence and length same as ThermalManagerLogLabel 7637a09cd7Sopenharmony_ci}; 7737a09cd7Sopenharmony_ci 7837a09cd7Sopenharmony_cistruct ThermalManagerLogLabelDomain { 7937a09cd7Sopenharmony_ci uint32_t domainId; 8037a09cd7Sopenharmony_ci const char* tag; 8137a09cd7Sopenharmony_ci}; 8237a09cd7Sopenharmony_ci 8337a09cd7Sopenharmony_ci// Keep the sequence and length same as ThermalManagerLogDomain 8437a09cd7Sopenharmony_cistatic const ThermalManagerLogLabelDomain THERMAL_LABEL[LABEL_END] = { 8537a09cd7Sopenharmony_ci {DOMAIN_APP, "ThermalApp"}, 8637a09cd7Sopenharmony_ci {DOMAIN_FRAMEWORK, "ThermalFwk"}, 8737a09cd7Sopenharmony_ci {DOMAIN_SERVICE, "ThermalSvc"}, 8837a09cd7Sopenharmony_ci {DOMAIN_HDI, "ThermalHdi"}, 8937a09cd7Sopenharmony_ci {DOMAIN_DRIVER, "ThermalDrv"}, 9037a09cd7Sopenharmony_ci {DOMAIN_FEATURE_PROTECTOR, "ThermalProtector"}, 9137a09cd7Sopenharmony_ci {DOMAIN_TEST, "ThermalTest"}, 9237a09cd7Sopenharmony_ci}; 9337a09cd7Sopenharmony_ci 9437a09cd7Sopenharmony_ci// In order to improve performance, do not check the module range, module should less than THERMALMGR_MODULE_BUTT. 9537a09cd7Sopenharmony_ci#define THERMAL_HILOGF(module, ...) \ 9637a09cd7Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, THERMAL_LABEL[module].domainId, THERMAL_LABEL[module].tag, ##__VA_ARGS__)) 9737a09cd7Sopenharmony_ci#define THERMAL_HILOGE(module, ...) \ 9837a09cd7Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, THERMAL_LABEL[module].domainId, THERMAL_LABEL[module].tag, ##__VA_ARGS__)) 9937a09cd7Sopenharmony_ci#define THERMAL_HILOGW(module, ...) \ 10037a09cd7Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, THERMAL_LABEL[module].domainId, THERMAL_LABEL[module].tag, ##__VA_ARGS__)) 10137a09cd7Sopenharmony_ci#define THERMAL_HILOGI(module, ...) \ 10237a09cd7Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, THERMAL_LABEL[module].domainId, THERMAL_LABEL[module].tag, ##__VA_ARGS__)) 10337a09cd7Sopenharmony_ci#define THERMAL_HILOGD(module, ...) \ 10437a09cd7Sopenharmony_ci ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, THERMAL_LABEL[module].domainId, THERMAL_LABEL[module].tag, ##__VA_ARGS__)) 10537a09cd7Sopenharmony_ci} // namespace PowerMgr 10637a09cd7Sopenharmony_ci} // namespace OHOS 10737a09cd7Sopenharmony_ci 10837a09cd7Sopenharmony_ci#else 10937a09cd7Sopenharmony_ci 11037a09cd7Sopenharmony_ci#define THERMAL_HILOGF(...) 11137a09cd7Sopenharmony_ci#define THERMAL_HILOGE(...) 11237a09cd7Sopenharmony_ci#define THERMAL_HILOGW(...) 11337a09cd7Sopenharmony_ci#define THERMAL_HILOGI(...) 11437a09cd7Sopenharmony_ci#define THERMAL_HILOGD(...) 11537a09cd7Sopenharmony_ci 11637a09cd7Sopenharmony_ci#endif // CONFIG_HILOG 11737a09cd7Sopenharmony_ci#endif // THERMAL_LOG_H 118