1 /* 2 * Copyright (c) 2023-2024 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 OHOS_ACE_UI_SERVICE_HILOG_H 17 #define OHOS_ACE_UI_SERVICE_HILOG_H 18 19 #include "hilog/log.h" 20 21 #define UISERVICE_LOG_DOMAIN 0xD003936 22 #define UISERVICE_LOG_TAG "AceUISession" 23 24 #define UISERVICE_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 25 #define ACE_FMT_PREFIX "[%{public}s:%{public}d]" 26 27 #ifdef IS_RELEASE_VERSION 28 #define PRINT_LOG(level, fmt, ...) \ 29 HILOG_IMPL(LOG_CORE, LOG_##level, UISERVICE_LOG_DOMAIN, UISERVICE_LOG_TAG, fmt, ##__VA_ARGS__) 30 #else 31 #define PRINT_LOG(level, fmt, ...) \ 32 HILOG_IMPL(LOG_CORE, LOG_##level, UISERVICE_LOG_DOMAIN, UISERVICE_LOG_TAG, ACE_FMT_PREFIX fmt, UISERVICE_FILENAME, \ 33 __LINE__, ##__VA_ARGS__) 34 #endif 35 36 #define LOGE(fmt, ...) PRINT_LOG(ERROR, fmt, ##__VA_ARGS__) 37 #define LOGW(fmt, ...) PRINT_LOG(WARN, fmt, ##__VA_ARGS__) 38 #define LOGI(fmt, ...) PRINT_LOG(INFO, fmt, ##__VA_ARGS__) 39 #define LOGD(fmt, ...) PRINT_LOG(DEBUG, fmt, ##__VA_ARGS__) 40 41 #endif 42