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 HILOG_WRAPPER_H 17 #define HILOG_WRAPPER_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 #ifdef LOG_LABEL 44 #undef LOG_LABEL 45 #endif 46 namespace OHOS { 47 namespace WallpaperMgrService { 48 static constexpr unsigned int WP_DOMAIN = 0xD001C00; 49 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, WP_DOMAIN, "Wallpaper_OS"}; 50 } 51 } 52 53 #define WALLFILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 54 55 #define HILOG_FATAL(fmt, ...) \ 56 (void)OHOS::HiviewDFX::HiLog::Fatal( \ 57 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, WALLFILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 58 #define HILOG_ERROR(fmt, ...) \ 59 (void)OHOS::HiviewDFX::HiLog::Error( \ 60 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, WALLFILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 61 #define HILOG_WARN(fmt, ...) \ 62 (void)OHOS::HiviewDFX::HiLog::Warn( \ 63 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, WALLFILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 64 #define HILOG_INFO(fmt, ...) \ 65 (void)OHOS::HiviewDFX::HiLog::Info( \ 66 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, WALLFILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 67 #define HILOG_DEBUG(fmt, ...) \ 68 (void)OHOS::HiviewDFX::HiLog::Debug( \ 69 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, WALLFILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) 70 #else 71 72 #define HILOG_FATAL(...) 73 #define HILOG_ERROR(...) 74 #define HILOG_WARN(...) 75 #define HILOG_INFO(...) 76 #define HILOG_DEBUG(...) 77 78 #endif // CONFIG_HILOG 79 80 #endif // HILOG_WRAPPER_H