• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 NEURAL_NETWORK_RUNTIME_LOG_H
17 #define NEURAL_NETWORK_RUNTIME_LOG_H
18 
19 #include <cstdarg>
20 #include "hilog/log.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #undef LOG_DOMAIN
27 #define LOG_DOMAIN 0xD002101
28 
29 #undef LOG_TAG
30 #define LOG_TAG "NNRt"
31 
32 #define R_FILENAME (__builtin_strrchr(__FILE_NAME__, '/') ? __builtin_strrchr(__FILE_NAME__, '/') + 1: __FILE_NAME__)
33 
34 #define LOGD(fmt, ...)                                                                                     \
35     ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, LOG_TAG, "[%{public}s(%{public}s:%{public}d)]" fmt, \
36         R_FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__))
37 
38 #define LOGI(fmt, ...)                                                                                     \
39     ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, LOG_DOMAIN, LOG_TAG, "[%{public}s(%{public}s:%{public}d)]" fmt, \
40         R_FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__))
41 
42 #define LOGW(fmt, ...)                                                                                     \
43     ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, LOG_DOMAIN, LOG_TAG, "[%{public}s(%{public}s:%{public}d)]" fmt, \
44         R_FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__))
45 
46 #define LOGE(fmt, ...)                                                                                     \
47     ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, LOG_DOMAIN, LOG_TAG, "[%{public}s(%{public}s:%{public}d)]" fmt, \
48         R_FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__))
49 
50 #define LOGF(fmt, ...)                                                                                     \
51     ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, LOG_DOMAIN, LOG_TAG, "[%{public}s(%{public}s:%{public}d)]" fmt, \
52         R_FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__))
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 
58 #endif // NEURAL_NETWORK_RUNTIME_LOG_H
59