1 /* 2 * Copyright (c) 2023 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 FORM_RENDERER_HILOG_H 17 #define FORM_RENDERER_HILOG_H 18 19 #define CONFIG_HILOG 20 #ifdef CONFIG_HILOG 21 #include "hilog/log.h" 22 23 #ifdef HILOG_FATAL 24 #undef HILOG_FATAL 25 #endif 26 27 #ifdef HILOG_ERROR 28 #undef HILOG_ERROR 29 #endif 30 31 #ifdef HILOG_WARN 32 #undef HILOG_WARN 33 #endif 34 35 #ifdef HILOG_INFO 36 #undef HILOG_INFO 37 #endif 38 39 #ifdef HILOG_DEBUG 40 #undef HILOG_DEBUG 41 #endif 42 43 #ifndef FR_LOG_DOMAIN 44 #define FR_LOG_DOMAIN 0xD0039FF 45 #endif 46 47 #ifndef FR_LOG_TAG 48 #define FR_LOG_TAG "FormRenderer" 49 #endif 50 51 #ifdef LOG_LABEL 52 #undef LOG_LABEL 53 #endif 54 55 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, FR_LOG_DOMAIN, FR_LOG_TAG}; 56 57 #define FR_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 58 #ifdef IS_RELEASE_VERSION 59 #define PRINT_HILOG(level, fmt, ...) \ 60 HILOG_IMPL(LOG_CORE, LOG_##level, FR_LOG_DOMAIN, FR_LOG_TAG, fmt, ##__VA_ARGS__) 61 #else 62 #define PRINT_HILOG(level, fmt, ...) \ 63 HILOG_IMPL(LOG_CORE, LOG_##level, FR_LOG_DOMAIN, FR_LOG_TAG, "[%{public}s:%{public}d]" fmt, \ 64 FR_FILENAME, __LINE__, ##__VA_ARGS__) 65 #endif 66 67 #define HILOG_FATAL(fmt, ...) PRINT_HILOG(FATAL, fmt, ##__VA_ARGS__) 68 #define HILOG_ERROR(fmt, ...) PRINT_HILOG(ERROR, fmt, ##__VA_ARGS__) 69 #define HILOG_WARN(fmt, ...) PRINT_HILOG(WARN, fmt, ##__VA_ARGS__) 70 #define HILOG_INFO(fmt, ...) PRINT_HILOG(INFO, fmt, ##__VA_ARGS__) 71 #define HILOG_DEBUG(fmt, ...) PRINT_HILOG(DEBUG, fmt, ##__VA_ARGS__) 72 #else 73 74 #define HILOG_FATAL(...) 75 #define HILOG_ERROR(...) 76 #define HILOG_WARN(...) 77 #define HILOG_INFO(...) 78 #define HILOG_DEBUG(...) 79 #endif // CONFIG_HILOG 80 81 #endif // FORM_RENDERER_HILOG_H 82