1 /* 2 * Copyright (c) 2022 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 PRINT_LOG 17 #define PRINT_LOG 18 19 #define CONFIG_PRINT_LOG 20 #ifdef CONFIG_PRINT_LOG 21 #include "hilog/log.h" 22 23 #ifdef PRINT_HILOGF 24 #undef PRINT_HILOGF 25 #endif 26 27 #ifdef PRINT_HILOGE 28 #undef PRINT_HILOGE 29 #endif 30 31 #ifdef PRINT_HILOGW 32 #undef PRINT_HILOGW 33 #endif 34 35 #ifdef PRINT_HILOGD 36 #undef PRINT_HILOGD 37 #endif 38 39 #ifdef PRINT_HILOGI 40 #undef PRINT_HILOGI 41 #endif 42 43 #define PRINT_LOG_TAG "printkit" 44 #define PRINT_LOG_DOMAIN 0xD001C00 45 46 #define MAKE_FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 47 48 #define PRINT_HILOGF(fmt, ...) \ 49 (void)HILOG_IMPL(LOG_CORE, LOG_FATAL, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 50 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 51 52 #define PRINT_HILOGE(fmt, ...) \ 53 (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 54 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 55 56 #define PRINT_HILOGW(fmt, ...) \ 57 (void)HILOG_IMPL(LOG_CORE, LOG_WARN, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 58 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 59 60 #define PRINT_HILOGD(fmt, ...) \ 61 (void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 62 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 63 64 #define PRINT_HILOGI(fmt, ...) \ 65 (void)HILOG_IMPL(LOG_CORE, LOG_INFO, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 66 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 67 68 #else 69 70 #define PRINT_HILOGF(fmt, ...) 71 #define PRINT_HILOGE(fmt, ...) 72 #define PRINT_HILOGW(fmt, ...) 73 #define PRINT_HILOGD(fmt, ...) 74 #define PRINT_HILOGI(fmt, ...) 75 #endif // CONFIG_PRINT_LOG 76 77 #endif /* PRINT_LOG */