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  #ifndef LOG_HELPER_H
16  #define LOG_HELPER_H
17  
18  #ifdef DEBUG
19  #include "hilog/log.h"
20  
21  #ifdef FatalLog
22  #undef FatalLog
23  #endif
24  
25  #ifdef ErrorLog
26  #undef ErrorLog
27  #endif
28  
29  #ifdef WarnLog
30  #undef WarnLog
31  #endif
32  
33  #ifdef InfoLog
34  #undef InfoLog
35  #endif
36  
37  #ifdef DebugLog
38  #undef DebugLog
39  #endif
40  
41  #ifdef LOG_DOMAIN
42  #undef LOG_DOMAIN
43  #endif
44  #define LOG_DOMAIN 0xD000301
45  
46  #ifdef LOG_TAG
47  #undef LOG_TAG
48  #endif
49  #define LOG_TAG "Nfc_Core"
50  
51  #define FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
52  
53  #define FatalLog(fmt, ...) HILOG_FATAL( \
54      LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
55  #define ErrorLog(fmt, ...) HILOG_ERROR( \
56      LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
57  #define WarnLog(fmt, ...) HILOG_WARN(  \
58      LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
59  #define InfoLog(fmt, ...) HILOG_INFO(  \
60      LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
61  #define DebugLog(fmt, ...) HILOG_DEBUG( \
62      LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
63  #else
64  
65  #define FatalLog(...)
66  #define ErrorLog(...)
67  #define WarnLog(...)
68  #define InfoLog(...)
69  #define DebugLog(...)
70  #endif  // DEBUG
71  
72  #endif // LOG_HELPER_H
73