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 OBJECT_STORE_LOGGER_H 17 #define OBJECT_STORE_LOGGER_H 18 #include <memory> 19 #ifdef HILOG_ENABLE 20 #include "hilog/log.h" 21 namespace OHOS::ObjectStore { 22 static const OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001652, "ObjectStore-x" }; 23 24 #define LOG_DEBUG(fmt, ...) \ 25 ((void)OHOS::HiviewDFX::HiLog::Debug( \ 26 LABEL, "%{public}d: %{public}s " fmt " ", __LINE__, __FUNCTION__, ##__VA_ARGS__)) 27 #define LOG_INFO(fmt, ...) \ 28 ((void)OHOS::HiviewDFX::HiLog::Info( \ 29 LABEL, "%{public}d: %{public}s " fmt " ", __LINE__, __FUNCTION__, ##__VA_ARGS__)) 30 #define LOG_WARN(fmt, ...) \ 31 ((void)OHOS::HiviewDFX::HiLog::Warn( \ 32 LABEL, "%{public}d: %{public}s " fmt " ", __LINE__, __FUNCTION__, ##__VA_ARGS__)) 33 #define LOG_ERROR(fmt, ...) \ 34 ((void)OHOS::HiviewDFX::HiLog::Error( \ 35 LABEL, "%{public}d: %{public}s " fmt " ", __LINE__, __FUNCTION__, ##__VA_ARGS__)) 36 #define LOG_FATAL(fmt, ...) \ 37 ((void)OHOS::HiviewDFX::HiLog::Fatal( \ 38 LABEL, "%{public}d: %{public}s " fmt " ", __LINE__, __FUNCTION__, ##__VA_ARGS__)) 39 } // namespace OHOS::ObjectStore 40 #else 41 #include <stdio.h> 42 #include <stdlib.h> 43 44 #define LOG_DEBUG(fmt, ...) \ 45 printf("[D][ObjectStore]%s:%d %s: " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 46 #define LOG_ERROR(fmt, ...) \ 47 printf("[E][ObjectStore]%s:%d %s: " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 48 #define LOG_INFO(fmt, ...) \ 49 printf("[I][ObjectStore]%s:%d %s: " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 50 #define LOG_WARN(fmt, ...) \ 51 printf("[W][ObjectStore]%s:%d %s: " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 52 #endif // #ifdef HILOG_ENABLE 53 #endif // OBJECT_STORE_LOGGER_H 54