1 /*
2  * Copyright (c) 2020 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 __LOG_H__
17 #define __LOG_H__
18 
19 typedef void (*log_f)(const char *tag, const char *func_name, const char *format, ...);
20 
21 struct log_f_group {
22     log_f log_d;
23     log_f log_i;
24     log_f log_w;
25     log_f log_e;
26 };
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 log_f get_logd(void);
32 log_f get_logi(void);
33 log_f get_logw(void);
34 log_f get_loge(void);
35 #ifdef __cplusplus
36 }
37 #endif
38 
39 #if !(defined(_CUT_LOG_))
40 #define DBG_OUT(...) get_logd()("[HiChain]", __func__, __VA_ARGS__)
41 #define LOGI(...) get_logi()("[HiChain]", __func__, __VA_ARGS__)
42 #define LOGW(...) get_logw()("[HiChain]", __func__, __VA_ARGS__)
43 #define LOGE(...) get_loge()("[HiChain]", __func__, __VA_ARGS__)
44 #else
45 #define DBG_OUT(...) {}
46 #define LOGI(...) {}
47 #define LOGW(...) {}
48 #define LOGE(...) {}
49 #endif
50 
51 #endif /* __LOG_H__ */
52