1 /* 2 * Copyright (c) 2023 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 DLP_LOG_H 17 #define DLP_LOG_H 18 19 #ifdef HILOG_ENABLE 20 21 #include "hilog/log.h" 22 23 #ifndef __cplusplus 24 25 #undef LOG_DOMAIN 26 #define LOG_DOMAIN 0xD005A04 27 28 #define DLP_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s:%{public}d]:" fmt, \ 29 __func__, __LINE__, ##__VA_ARGS__) 30 #define DLP_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s:%{public}d]:" fmt, \ 31 __func__, __LINE__, ##__VA_ARGS__) 32 #define DLP_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s:%{public}d]:" fmt, \ 33 __func__, __LINE__, ##__VA_ARGS__) 34 #define DLP_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s:%{public}d]:" fmt, \ 35 __func__, __LINE__, ##__VA_ARGS__) 36 #define DLP_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s:%{public}d]:" fmt, \ 37 __func__, __LINE__, ##__VA_ARGS__) 38 39 #else 40 41 static constexpr unsigned int SECURITY_DOMAIN_DLP_PERMISSION = 0xD005A04; 42 43 #define DLP_LOG_DEBUG(label, fmt, ...) \ 44 OHOS::HiviewDFX::HiLog::Debug(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__) 45 #define DLP_LOG_INFO(label, fmt, ...) OHOS::HiviewDFX::HiLog::Info(label, "[%{public}s:%{public}d]:" fmt, \ 46 __func__, __LINE__, ##__VA_ARGS__) 47 #define DLP_LOG_WARN(label, fmt, ...) OHOS::HiviewDFX::HiLog::Warn(label, "[%{public}s:%{public}d]:" fmt, \ 48 __func__, __LINE__, ##__VA_ARGS__) 49 #define DLP_LOG_ERROR(label, fmt, ...) \ 50 OHOS::HiviewDFX::HiLog::Error(label, "[%{public}s:%{public}d]:" fmt, \ 51 __func__, __LINE__, ##__VA_ARGS__) 52 #define DLP_LOG_FATAL(label, fmt, ...) \ 53 OHOS::HiviewDFX::HiLog::Fatal(label, "[%{public}s:%{public}d]:" fmt, \ 54 __func__, __LINE__, ##__VA_ARGS__) 55 56 #endif // __cplusplus 57 58 #else 59 60 #include <cstdio> 61 62 #undef LOG_TAG 63 64 #define DLP_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 65 #define DLP_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 66 #define DLP_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 67 #define DLP_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 68 #define DLP_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__) 69 70 #endif // HILOG_ENABLE 71 72 #endif // DLP_LOG_H 73