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 /* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ 24 #undef LOG_TAG 25 #undef LOG_DOMAIN 26 27 static constexpr unsigned int SECURITY_DOMAIN_ACCESSTOKEN = 0xD005A01; 28 static constexpr unsigned int SECURITY_DOMAIN_PRIVACY = 0xD005A02; 29 30 #define ACCESSTOKEN_LOG_FATAL(label, fmt, ...) \ 31 ((void)HILOG_IMPL(label.type, LOG_FATAL, label.domain, label.tag, \ 32 "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)) 33 #define ACCESSTOKEN_LOG_ERROR(label, fmt, ...) \ 34 ((void)HILOG_IMPL(label.type, LOG_ERROR, label.domain, label.tag, \ 35 "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)) 36 #define ACCESSTOKEN_LOG_WARN(label, fmt, ...) \ 37 ((void)HILOG_IMPL(label.type, LOG_WARN, label.domain, label.tag, \ 38 "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)) 39 #define ACCESSTOKEN_LOG_INFO(label, fmt, ...) \ 40 ((void)HILOG_IMPL(label.type, LOG_INFO, label.domain, label.tag, \ 41 "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)) 42 #define ACCESSTOKEN_LOG_DEBUG(label, fmt, ...) \ 43 ((void)HILOG_IMPL(label.type, LOG_DEBUG, label.domain, label.tag, \ 44 "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)) 45 46 #else 47 48 #include <stdarg.h> 49 #include <stdio.h> 50 51 /* define LOG_TAG as "security_*" at your submodule, * means your submodule name such as "security_dac" */ 52 #undef LOG_TAG 53 54 #define ACCESSTOKEN_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 55 #define ACCESSTOKEN_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 56 #define ACCESSTOKEN_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 57 #define ACCESSTOKEN_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 58 #define ACCESSTOKEN_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 59 60 #endif // HILOG_ENABLE 61 62 #endif // ACCESSTOKEN_LOG_H 63