3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef __CALENDAR_LOG_H__
20 #define __CALENDAR_LOG_H__
25 //#define CAL_TIMECHECK
26 //#define CAL_USE_OWN_TIME
29 #define LOG_TAG "CALENDAR"
31 #define DLOG(prio, fmt, arg...) \
32 do { SLOG(prio, LOG_TAG, fmt, ##arg); } while (0)
33 #define INFO(fmt, arg...) SLOGI(fmt, ##arg)
34 #define ERR(fmt, arg...) SLOGE(fmt, ##arg)
35 #define DBG(fmt, arg...) SLOGD(fmt, ##arg)
37 #define PRT(prio, fmt, arg...) \
38 do { fprintf((prio?stderr:stdout),"[Calendar]" fmt"\n", ##arg); } while (0)
39 #define INFO(fmt, arg...) PRT(0, fmt, ##arg)
40 #define ERR(fmt, arg...) PRT(1,"%s(%d) " fmt, ##arg)
41 #define DBG(fmt, arg...) \
43 printf("\x1b[105;37m[Calendar]\x1b[0m" fmt "\n", ##arg); \
49 #ifdef CAL_USE_OWN_TIME
50 #define CAL_FN_START CAL_TIME_CHECK_START
51 #define CAL_FN_END CAL_TIME_CHECK_END
52 #else//CAL_USE_OWN_TIME
54 #define CAL_FN_START DBG("START")
55 #define CAL_FN_END DBG("END")
57 #define CAL_FN_START DBG("")
60 #endif//CAL_USE_OWN_TIME
62 #define c_warn_if(expr, fmt, arg...) do { \
64 ERR("(%s) -> "fmt, #expr, ##arg); \
67 #define c_ret_if(expr) do { \
69 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
73 #define c_retv_if(expr, val) do { \
75 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
79 #define c_retm_if(expr, fmt, arg...) do { \
82 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
86 #define c_retvm_if(expr, val, fmt, arg...) do { \
89 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
98 #define c_warn_if(expr, fmt, arg...) do { \
103 #define c_ret_if(expr) do { \
108 #define c_retv_if(expr, val) do { \
113 #define c_retm_if(expr, fmt, arg...) do { \
119 #define c_retvm_if(expr, val, fmt, arg...) do { \
126 #endif //CAL_DEBUGGING
129 double cal_correction, cal_startT;
130 double cal_set_start_time(void);
131 double cal_exec_time(double start, double correction);
132 double cal_init_time(double correction);
133 #define CAL_TIME_CHECK_START \
134 double cal_startT = 0, cal_correction = 0; \
135 cal_correction = cal_init_time(cal_correction);\
136 cal_startT = cal_set_start_time();
137 #define CAL_TIME_CHECK_END DBG("time = %f ms\n", cal_exec_time(cal_startT, cal_correction));
138 #else //CAL_TIMECHECK
139 #define CAL_TIME_CHECK_START
140 #define CAL_TIME_CHECK_END
141 #endif //CAL_TIMECHECK
144 #endif /* __CALENDAR_LOG_H__ */