• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 _HC_DEBUG_
17 
18 #include "log.h"
19 #include "securec.h"
20 #include "base.h"
21 
22 #if defined(_WINDOWS)
23 #ifdef DLL_EXPORT
24 #define DLL_API_PUBLIC __declspec(dllexport)
25 #else
26 #define DLL_API_PUBLIC __declspec(dllimport)
27 #endif
28 #else
29 #define DLL_API_PUBLIC __attribute__ ((visibility("default")))
30 #endif
31 
32 static void hc_logd(const char *tag, const char *func, const char *format, ...);
33 static void hc_logi(const char *tag, const char *func, const char *format, ...);
34 static void hc_logw(const char *tag, const char *func, const char *format, ...);
35 static void hc_loge(const char *tag, const char *func, const char *format, ...);
36 
37 static struct log_f_group g_log_func = { hc_logd, hc_logi, hc_logw, hc_loge };
38 
get_logd(void)39 log_f get_logd(void)
40 {
41     return g_log_func.log_d;
42 }
43 
get_logi(void)44 log_f get_logi(void)
45 {
46     return g_log_func.log_i;
47 }
48 
get_logw(void)49 log_f get_logw(void)
50 {
51     return g_log_func.log_w;
52 }
53 
get_loge(void)54 log_f get_loge(void)
55 {
56     return g_log_func.log_e;
57 }
58 
59 /* no log without register */
registe_log(struct log_f_group * log)60 DLL_API_PUBLIC void registe_log(struct log_f_group *log)
61 {
62     check_ptr_return(log);
63 
64     if (log->log_d != NULL) {
65         g_log_func.log_d = log->log_d;
66     }
67     if (log->log_i != NULL) {
68         g_log_func.log_i = log->log_i;
69     }
70     if (log->log_w != NULL) {
71         g_log_func.log_w = log->log_w;
72     }
73     if (log->log_e != NULL) {
74         g_log_func.log_e = log->log_e;
75     }
76 }
77 
hc_logd(const char * tag,const char * func,const char * format,...)78 static void hc_logd(const char *tag, const char *func, const char *format, ...)
79 {
80     (void)tag;
81     (void)func;
82     (void)format;
83 }
84 
hc_logi(const char * tag,const char * func,const char * format,...)85 static void hc_logi(const char *tag, const char *func, const char *format, ...)
86 {
87     (void)tag;
88     (void)func;
89     (void)format;
90 }
91 
hc_logw(const char * tag,const char * func,const char * format,...)92 static void hc_logw(const char *tag, const char *func, const char *format, ...)
93 {
94     (void)tag;
95     (void)func;
96     (void)format;
97 }
98 
hc_loge(const char * tag,const char * func,const char * format,...)99 static void hc_loge(const char *tag, const char *func, const char *format, ...)
100 {
101     (void)tag;
102     (void)func;
103     (void)format;
104 };
105 #endif /* _HC_DEBUG_ */
106