Base patch (skeleton code)
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-lib / include / zblib_log.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Contact: Suresh Kumar N (suresh.n@samsung.com)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __ZIGBEE_LIB_LOG_H__
20 #define __ZIGBEE_LIB_LOG_H__
21
22 #include <glib.h>
23
24 #define TIZEN_DEBUG_ENABLE
25
26 /**< ZigBee debug flag */
27 extern gboolean zblib_debug;
28
29 #ifndef ZIGBEE_LOG_TAG
30 #define ZIGBEE_LOG_TAG "UNKNOWN"
31 #endif
32
33 enum zblib_log_type {
34         ZIGBEE_LOG_TYPE_MAIN = 0,
35         ZIGBEE_LOG_TYPE_RADIO,
36         ZIGBEE_LOG_TYPE_SYSTEM,
37         ZIGBEE_LOG_TYPE_TIME_CHECK
38 };
39
40 enum zblib_log_priority {
41         ZIGBEE_LOG_UNKNOWN = 0,
42         ZIGBEE_LOG_DEFAULT,
43         ZIGBEE_LOG_VERBOSE,
44         ZIGBEE_LOG_DEBUG,
45         ZIGBEE_LOG_INFO,
46         ZIGBEE_LOG_WARN,
47         ZIGBEE_LOG_ERROR,
48         ZIGBEE_LOG_FATAL,
49         ZIGBEE_LOG_SILENT
50 };
51
52 void zblib_log(enum zblib_log_type type, enum zblib_log_priority priority, const char *tag, const char *fmt, ...);
53
54 /* Logs would be available in system logs */
55 #define Z_LOGI(fmt,args...)  do { if(zblib_debug) zblib_log(ZIGBEE_LOG_TYPE_SYSTEM, ZIGBEE_LOG_INFO, ZIGBEE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); } while (0)
56 #define Z_LOGM(fmt,args...)  do { if(zblib_debug) zblib_log(ZIGBEE_LOG_TYPE_SYSTEM, ZIGBEE_LOG_INFO, ZIGBEE_LOG_TAG, fmt "\n", ##args); } while (0)
57 #define Z_LOGD(fmt,args...)  do { if(zblib_debug) zblib_log(ZIGBEE_LOG_TYPE_SYSTEM, ZIGBEE_LOG_DEBUG, ZIGBEE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); } while (0)
58 #define Z_LOGW(fmt,args...)  do { zblib_log(ZIGBEE_LOG_TYPE_SYSTEM, ZIGBEE_LOG_WARN, ZIGBEE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); } while (0)
59 #define Z_LOGE(fmt,args...)  do { zblib_log(ZIGBEE_LOG_TYPE_SYSTEM, ZIGBEE_LOG_ERROR, ZIGBEE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); } while (0)
60 #define Z_LOGF(fmt,args...)  do { zblib_log(ZIGBEE_LOG_TYPE_SYSTEM, ZIGBEE_LOG_FATAL, ZIGBEE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); } while (0)
61
62 #define Z_TIME_CHECK(fmt,args...) do { zblib_log(ZIGBEE_LOG_TYPE_TIME_CHECK, ZIGBEE_LOG_INFO, "TIME_CHECK", fmt "\n", ##args); } while (0)
63
64 #endif /* __ZIGBEE_LIB_LOG_H__ */