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 BASE_SMALLSERVICE_SCLOCK_LOG_H 17 #define BASE_SMALLSERVICE_SCLOCK_LOG_H 18 19 #include <cstdint> 20 21 #define CONFIG_SCLOCK_HILOG 22 #ifdef CONFIG_SCLOCK_HILOG 23 #include "hilog/log.h" 24 25 #ifdef SCLOCK_HILOGI 26 #undef SCLOCK_HILOGI 27 #endif 28 29 #ifdef SCLOCK_HILOGE 30 #undef SCLOCK_HILOGE 31 #endif 32 33 #ifdef SCLOCK_HILOGW 34 #undef SCLOCK_HILOGW 35 #endif 36 37 #ifdef SCLOCK_HILOGI 38 #undef SCLOCK_HILOGI 39 #endif 40 41 #ifdef SCLOCK_HILOGD 42 #undef SCLOCK_HILOGD 43 #endif 44 45 constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, 0xD001C00, "SclockKit" }; 46 47 #define FILENAME_PREFIX (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 48 49 #define SCLOCK_HILOGF(fmt, ...) \ 50 (void)OHOS::HiviewDFX::HiLog::Fatal( \ 51 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME_PREFIX, __FUNCTION__, __LINE__, ##__VA_ARGS__) 52 #define SCLOCK_HILOGE(fmt, ...) \ 53 (void)OHOS::HiviewDFX::HiLog::Error( \ 54 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME_PREFIX, __FUNCTION__, __LINE__, ##__VA_ARGS__) 55 #define SCLOCK_HILOGW(fmt, ...) \ 56 (void)OHOS::HiviewDFX::HiLog::Warn( \ 57 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME_PREFIX, __FUNCTION__, __LINE__, ##__VA_ARGS__) 58 #define SCLOCK_HILOGI(fmt, ...) \ 59 (void)OHOS::HiviewDFX::HiLog::Info( \ 60 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME_PREFIX, __FUNCTION__, __LINE__, ##__VA_ARGS__) 61 #define SCLOCK_HILOGD(fmt, ...) \ 62 (void)OHOS::HiviewDFX::HiLog::Debug( \ 63 LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME_PREFIX, __FUNCTION__, __LINE__, ##__VA_ARGS__) 64 #else 65 66 #define SCLOCK_HILOGF(...) 67 #define SCLOCK_HILOGE(...) 68 #define SCLOCK_HILOGW(...) 69 #define SCLOCK_HILOGI(...) 70 #define SCLOCK_HILOGD(...) 71 #endif // CONFIG_HILOG 72 #endif // BASE_SMALLSERVICE_SCLOCK_LOG_H 73