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 FILEMGMT_LIBHILOG_H 17 #define FILEMGMT_LIBHILOG_H 18 19 #include "hilog/log.h" 20 21 #include <string> 22 23 namespace OHOS { 24 #ifndef LOG_DOMAIN 25 #define LOG_DOMAIN 0xD001600 26 #endif 27 28 #ifndef LOG_TAG 29 #define LOG_TAG "FileManagement" 30 #endif 31 32 static constexpr HiviewDFX::HiLogLabel FILEMGMT_LOG_LABEL = {LOG_CORE, LOG_DOMAIN, LOG_TAG}; 33 34 #if defined __FILE_NAME__ 35 #define FILEMGMT_FILE_NAME __FILE_NAME__ 36 #else 37 #include <cstring> 38 #define FILEMGMT_FILE_NAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) 39 #endif 40 41 #define FILEMGMT_PRINT_LOG(Level, fmt, ...) \ 42 HiviewDFX::HiLog::Level(FILEMGMT_LOG_LABEL, "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, \ 43 __LINE__, __FUNCTION__, ##__VA_ARGS__) 44 45 #define HILOGD(fmt, ...) FILEMGMT_PRINT_LOG(Debug, fmt, ##__VA_ARGS__) 46 #define HILOGI(fmt, ...) FILEMGMT_PRINT_LOG(Info, fmt, ##__VA_ARGS__) 47 #define HILOGW(fmt, ...) FILEMGMT_PRINT_LOG(Warn, fmt, ##__VA_ARGS__) 48 #define HILOGE(fmt, ...) FILEMGMT_PRINT_LOG(Error, fmt, ##__VA_ARGS__) 49 #define HILOGF(fmt, ...) FILEMGMT_PRINT_LOG(Fatal, fmt, ##__VA_ARGS__) 50 } // namespace OHOS 51 52 #endif // FILEMGMT_LIBHILOG_H