1 /**************************************************************************
5 Copyright 2018 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
8 Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
36 #include <sys/syscall.h>
45 * @brief The header file to print logs in frontend and backend modules
57 void tbm_log_enable_color(unsigned int enable);
58 void tbm_log_enable_dlog(unsigned int enable);
59 void tbm_log_set_debug_level(int level);
60 void tbm_log_set_assert_level(int level);
61 void tbm_log_set_path(const char *path);
62 void tbm_log_print(int level, const char *fmt, ...);
63 void tbm_log_print_stdout(int level, const char *fmt, ...);
65 #define TBM_DBG(fmt, args...) \
68 clock_gettime(CLOCK_MONOTONIC, &ts); \
69 tbm_log_print(TBM_LOG_LEVEL_DBG, "[%5d.%06d][%d][%s %d]"fmt, \
70 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
71 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
73 #define TBM_INFO(fmt, args...) \
76 clock_gettime(CLOCK_MONOTONIC, &ts); \
77 tbm_log_print(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt, \
78 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
79 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
81 #define TBM_WRN(fmt, args...) \
84 clock_gettime(CLOCK_MONOTONIC, &ts); \
85 tbm_log_print(TBM_LOG_LEVEL_WRN, "[%5d.%06d][%d][%s %d]"fmt, \
86 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
87 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
89 #define TBM_ERR(fmt, args...) \
92 clock_gettime(CLOCK_MONOTONIC, &ts); \
93 tbm_log_print(TBM_LOG_LEVEL_ERR, "[%5d.%06d][%d][%s %d]"fmt, \
94 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
95 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
98 #define TBM_STDOUT_INFO(fmt, args...) \
100 struct timespec ts; \
101 clock_gettime(CLOCK_MONOTONIC, &ts); \
102 tbm_log_print_stdout(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt, \
103 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
104 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
107 #define TBM_NEVER_GET_HERE() TBM_WRN("** NEVER GET HERE **")
108 #define TBM_DEPRECATED(str) \
111 TBM_WRN("** DEPRECATED: %s **", str); \
113 TBM_WRN("** DEPRECATED **"); \
116 /* check condition */
117 #define TBM_RETURN_IF_FAIL(cond) {\
119 TBM_ERR("'%s' failed.\n", #cond);\
123 #define TBM_RETURN_VAL_IF_FAIL(cond, val) {\
125 TBM_ERR("'%s' failed.\n", #cond);\
129 #define TBM_GOTO_VAL_IF_FAIL(cond, val) {\
131 TBM_ERR("'%s' failed.\n", #cond);\
136 #define TBM_RETURN_SET_ERR_IF_FAIL(cond, error, error_type) {\
138 TBM_ERR("'%s' failed.\n", #cond);\
144 #define TBM_RETURN_VAL_SET_ERR_IF_FAIL(cond, val, error, error_type) {\
146 TBM_ERR("'%s' failed.\n", #cond);\
156 #endif /* _TBM_LOG_H_ */