1 /* 2 * Copyright (c) 2021-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 ACCESSTOKEN_LOG_H 17 #define ACCESSTOKEN_LOG_H 18 19 #ifdef HILOG_ENABLE 20 21 #include "hilog/log.h" 22 23 #ifndef __cplusplus 24 25 #define ACCESSTOKEN_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 26 #define ACCESSTOKEN_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 27 #define ACCESSTOKEN_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 28 #define ACCESSTOKEN_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 29 #define ACCESSTOKEN_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 30 31 #else 32 33 #define ACCESSTOKEN_LOG_DEBUG(label, fmt, ...) \ 34 OHOS::HiviewDFX::HiLog::Debug(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 35 #define ACCESSTOKEN_LOG_INFO(label, fmt, ...) \ 36 OHOS::HiviewDFX::HiLog::Info(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 37 #define ACCESSTOKEN_LOG_WARN(label, fmt, ...) \ 38 OHOS::HiviewDFX::HiLog::Warn(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 39 #define ACCESSTOKEN_LOG_ERROR(label, fmt, ...) \ 40 OHOS::HiviewDFX::HiLog::Error(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 41 #define ACCESSTOKEN_LOG_FATAL(label, fmt, ...) \ 42 OHOS::HiviewDFX::HiLog::Fatal(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 43 44 #endif // __cplusplus 45 46 /* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ 47 #undef LOG_TAG 48 #undef LOG_DOMAIN 49 50 static constexpr unsigned int SECURITY_DOMAIN_ACCESSTOKEN = 0xD002F01; 51 static constexpr unsigned int SECURITY_DOMAIN_PRIVACY = 0xD002F03; 52 53 #else 54 55 #include <stdarg.h> 56 #include <stdio.h> 57 58 /* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ 59 #undef LOG_TAG 60 61 #define ACCESSTOKEN_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 62 #define ACCESSTOKEN_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 63 #define ACCESSTOKEN_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 64 #define ACCESSTOKEN_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 65 #define ACCESSTOKEN_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 66 67 #endif // HILOG_ENABLE 68 69 #endif // ACCESSTOKEN_LOG_H 70