1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SERVICES_SAFWK_NATIVE_INCLUDE_SAM_LOG_H 17 #define SERVICES_SAFWK_NATIVE_INCLUDE_SAM_LOG_H 18 19 #include "hilog/log.h" 20 21 namespace OHOS { 22 23 constexpr OHOS::HiviewDFX::HiLogLabel SAFWK_LABEL = { 24 LOG_KMSG, 25 0xD001810, 26 "SAFWK" 27 }; 28 29 #undef LOG_DOMAIN 30 #define LOG_DOMAIN 0xD001810 31 32 #undef LOG_TAG 33 #define LOG_TAG "SAFWK" 34 35 #ifdef HILOGF 36 #undef HILOGF 37 #endif 38 39 #ifdef HILOGE 40 #undef HILOGE 41 #endif 42 43 #ifdef HILOGW 44 #undef HILOGW 45 #endif 46 47 #ifdef HILOGI 48 #undef HILOGI 49 #endif 50 51 #ifdef HILOGD 52 #undef HILOGD 53 #endif 54 55 #ifdef KHILOGI 56 #undef KHILOGI 57 #endif 58 59 #ifdef LOGI 60 #undef LOGI 61 #endif 62 63 #ifdef LOGW 64 #undef LOGW 65 #endif 66 67 #ifdef LOGE 68 #undef LOGE 69 #endif 70 71 #ifdef LOGD 72 #undef LOGD 73 #endif 74 75 #ifdef LOGF 76 #undef LOGF 77 #endif 78 79 #define KHILOGI(TAG, fmt, ...) \ 80 do { \ 81 (void)OHOS::HiviewDFX::HiLog::Info(SAFWK_LABEL, "%{public}s " fmt, __FUNCTION__, ##__VA_ARGS__); \ 82 HILOG_INFO(LOG_CORE, "%{public}s " fmt, __FUNCTION__, ##__VA_ARGS__); \ 83 } while (0) 84 85 #define LOGI(...) HILOG_INFO(LOG_CORE, __VA_ARGS__) 86 #define LOGW(...) HILOG_WARN(LOG_CORE, __VA_ARGS__) 87 #define LOGE(...) HILOG_ERROR(LOG_CORE, __VA_ARGS__) 88 #define LOGD(...) HILOG_DEBUG(LOG_CORE, __VA_ARGS__) 89 #define LOGF(...) HILOG_FATAL(LOG_CORE, __VA_ARGS__) 90 91 #define HILOGF(TAG, fmt, ...) \ 92 HILOG_FATAL(LOG_CORE, "%{public}s " fmt, __FUNCTION__, ##__VA_ARGS__) 93 #define HILOGE(TAG, fmt, ...) \ 94 HILOG_ERROR(LOG_CORE, "%{public}s " fmt, __FUNCTION__, ##__VA_ARGS__) 95 #define HILOGW(TAG, fmt, ...) \ 96 HILOG_WARN(LOG_CORE, "%{public}s " fmt, __FUNCTION__, ##__VA_ARGS__) 97 #define HILOGI(TAG, fmt, ...) \ 98 HILOG_INFO(LOG_CORE, "%{public}s " fmt, __FUNCTION__, ##__VA_ARGS__) 99 #define HILOGD(TAG, fmt, ...) \ 100 HILOG_DEBUG(LOG_CORE, "%{public}s " fmt, __FUNCTION__, ##__VA_ARGS__) 101 } 102 103 #endif 104