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 REQUEST_LOG 17 #define REQUEST_LOG 18 19 #ifndef CONFIG_REQUEST_TEST 20 #include "hilog/log.h" 21 22 #ifdef REQUEST_HILOGF 23 #undef REQUEST_HILOGF 24 #endif 25 26 #ifdef REQUEST_HILOGE 27 #undef REQUEST_HILOGE 28 #endif 29 30 #ifdef REQUEST_HILOGW 31 #undef REQUEST_HILOGW 32 #endif 33 34 #ifdef REQUEST_HILOGD 35 #undef REQUEST_HILOGD 36 #endif 37 38 #ifdef REQUEST_HILOGI 39 #undef REQUEST_HILOGI 40 #endif 41 42 #define REQUEST_LOG_TAG "RequestCxx" 43 #define REQUEST_LOG_DOMAIN 0xD001C50 44 static constexpr OHOS::HiviewDFX::HiLogLabel REQUEST_LOG_LABEL = { LOG_CORE, REQUEST_LOG_DOMAIN, REQUEST_LOG_TAG }; 45 46 #define MAKE_FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 47 48 #define REQUEST_HILOGF(fmt, ...) \ 49 (void)HILOG_IMPL(LOG_CORE, LOG_FATAL, REQUEST_LOG_LABEL.domain, REQUEST_LOG_LABEL.tag, \ 50 "[%{public}s %{public}s %{public}d] " fmt, MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 51 52 #define REQUEST_HILOGE(fmt, ...) \ 53 (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, REQUEST_LOG_LABEL.domain, REQUEST_LOG_LABEL.tag, \ 54 "[%{public}s %{public}s %{public}d] " fmt, MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 55 56 #define REQUEST_HILOGW(fmt, ...) \ 57 (void)HILOG_IMPL(LOG_CORE, LOG_WARN, REQUEST_LOG_LABEL.domain, REQUEST_LOG_LABEL.tag, \ 58 "[%{public}s %{public}s %{public}d] " fmt, MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 59 60 #define REQUEST_HILOGD(fmt, ...) \ 61 (void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, REQUEST_LOG_LABEL.domain, REQUEST_LOG_LABEL.tag, \ 62 "[%{public}s %{public}s %{public}d] " fmt, MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 63 64 #define REQUEST_HILOGI(fmt, ...) \ 65 (void)HILOG_IMPL(LOG_CORE, LOG_INFO, REQUEST_LOG_LABEL.domain, REQUEST_LOG_LABEL.tag, \ 66 "[%{public}s %{public}s %{public}d] " fmt, MAKE_FILE_NAME, __FUNCTION__, __LINE__, ##__VA_ARGS__) 67 68 #else 69 70 #define REQUEST_HILOGF(fmt, ...) 71 #define REQUEST_HILOGE(fmt, ...) 72 #define REQUEST_HILOGW(fmt, ...) 73 #define REQUEST_HILOGD(fmt, ...) 74 #define REQUEST_HILOGI(fmt, ...) 75 #endif // CONFIG_REQUEST_LOG 76 77 #endif /* REQUEST_LOG */