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 #ifdef IS_RELEASE_VERSION 47 #define MAKE_FILE_NAME "" 48 #else 49 #define MAKE_FILE_NAME \ 50 (__builtin_strrchr(__FILE_NAME__, '/') ? __builtin_strrchr(__FILE_NAME__, '/') + 1 : __FILE_NAME__) 51 #endif 52 53 #define PRINT_HILOGF(fmt, ...) \ 54 (void)HILOG_IMPL(LOG_CORE, LOG_FATAL, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 55 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 56 57 #define PRINT_HILOGE(fmt, ...) \ 58 (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 59 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 60 61 #define PRINT_HILOGW(fmt, ...) \ 62 (void)HILOG_IMPL(LOG_CORE, LOG_WARN, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 63 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 64 65 #define PRINT_HILOGD(fmt, ...) \ 66 (void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 67 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 68 69 #define PRINT_HILOGI(fmt, ...) \ 70 (void)HILOG_IMPL(LOG_CORE, LOG_INFO, PRINT_LOG_DOMAIN, PRINT_LOG_TAG, "[%{public}s %{public}s %{public}d] " fmt, \ 71 MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 72 73 #else 74 75 #define PRINT_HILOGF(fmt, ...) 76 #define PRINT_HILOGE(fmt, ...) 77 #define PRINT_HILOGW(fmt, ...) 78 #define PRINT_HILOGD(fmt, ...) 79 #define PRINT_HILOGI(fmt, ...) 80 #endif // CONFIG_PRINT_LOG 81 82 #endif /* PRINT_LOG */