3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
23 #endif /* __cplusplus */
33 * @brief Provides logging macro
36 /** @addtogroup utility
40 #define COLOR_BLACK "\033[0;30m"
41 #define COLOR_RED "\033[0;31m"
42 #define COLOR_GREEN "\033[0;32m"
43 #define COLOR_YELLOW "\033[0;33m"
44 #define COLOR_BLUE "\033[0;34m"
45 #define COLOR_MARGENTA "\033[0;35m"
46 #define COLOR_CYAN "\033[0;36m"
47 #define COLOR_WHITE "\033[0;37m"
48 #define COLOR_END "\033[0;m"
50 #if COMPONENT_TAG == SYSTEM
51 #define _DEBUG_VERBOSE(fmt, args...) SLOGV(" " fmt, ##args)
52 #define _DEBUG_TRACE(fmt, args...) SLOGD(" " fmt, ##args)
53 #define _DEBUG_INFO(fmt, args...) SLOGI(COLOR_YELLOW fmt COLOR_END, ##args)
54 #define _DEBUG_WARNING(fmt, args...) SLOGW(COLOR_MARGENTA" * Warning * " fmt COLOR_END, ##args)
55 #define _DEBUG_ERROR(fmt, args...) SLOGE(COLOR_RED" * Critical * " fmt COLOR_END, ##args)
56 #define _INNER_FUNC_ENTER SLOGD(COLOR_CYAN" ENTER >>>"COLOR_END)
57 #define _INNER_FUNC_EXIT SLOGD(COLOR_CYAN" EXIT <<<"COLOR_END)
58 #define _EXTERN_FUNC_ENTER SLOGI(COLOR_GREEN" ENTER >>>"COLOR_END)
59 #define _EXTERN_FUNC_EXIT SLOGI(COLOR_GREEN" EXIT <<<"COLOR_END)
60 #elif COMPONENT_TAG == APP
61 #define _DEBUG_VERBOSE(fmt, args...) ALOGV(" " fmt, ##args)
62 #define _DEBUG_TRACE(fmt, args...) ALOGD(" " fmt, ##args)
63 #define _DEBUG_INFO(fmt, args...) ALOGI(COLOR_YELLOW fmt COLOR_END, ##args)
64 #define _DEBUG_WARNING(fmt, args...) ALOGW(COLOR_MARGENTA" * Warning * " fmt COLOR_END, ##args)
65 #define _DEBUG_ERROR(fmt, args...) ALOGE(COLOR_RED" * Critical * " fmt COLOR_END, ##args)
66 #define _INNER_FUNC_ENTER ALOGD(COLOR_CYAN" ENTER >>>"COLOR_END)
67 #define _INNER_FUNC_EXIT ALOGD(COLOR_CYAN" EXIT <<<"COLOR_END)
68 #define _EXTERN_FUNC_ENTER ALOGI(COLOR_GREEN" ENTER >>>"COLOR_END)
69 #define _EXTERN_FUNC_EXIT ALOGI(COLOR_GREEN" EXIT <<<"COLOR_END)
72 #define warn_if(expr, fmt, arg...) \
75 _DEBUG_WARNING(fmt, ##arg); \
78 #define ret_if(expr) \
84 #define retv_if(expr, val)\
90 #define retm_if(expr, fmt, arg...) \
93 _DEBUG_ERROR(fmt, ##arg); \
97 #define retvm_if(expr, val, fmt, arg...) \
100 _DEBUG_ERROR(fmt, ##arg); \
105 #define _ASSERT(cond, ret) \
108 _DEBUG_ERROR("_ASSERT fails"); \
112 #define goto_if(expr, fmt, arg...) \
115 _DEBUG_ERROR(fmt, ##arg); \
121 * API to daemonize client agent
125 if (sync_agent_daemonize() < 0) {
126 _DEBUG_ERROR("daemonize error");
133 * @return 0 on success, -1 on error
138 * @see sync_agent_daemonize()
141 int sync_agent_daemonize(void);
149 #endif /* __cplusplus */
150 #endif /* SYNC_UTIL_H_ */