X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Ftdm_log.h;h=3d0ea6202239ce97f00b838bd5507978f38e7b4a;hb=refs%2Fchanges%2F65%2F173665%2F1;hp=ebfa1d76f29eed7be62cdebdf507042b04af3f2e;hpb=acab1c4c70fb532947a941c3514249346a07e338;p=platform%2Fcore%2Fuifw%2Flibtdm.git diff --git a/include/tdm_log.h b/include/tdm_log.h index ebfa1d7..3d0ea62 100644 --- a/include/tdm_log.h +++ b/include/tdm_log.h @@ -1,165 +1,130 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + * + * libtdm + * + * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Eunchul Kim , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * **************************************************************************/ #ifndef _TDM_LOG_H_ #define _TDM_LOG_H_ +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -#include -#include -#include -#include - - /** * @file tdm_log.h * @brief The header file to print logs in frontend and backend modules * @details - * The TDM debug log can be enable by setting "TDM_DEBUG" enviroment + * The TDM debug log can be enable by setting "TDM_DEBUG" enviroment. And also, + * the TDM dlog can be enable by setting "TDM_DLOG" enviroment. * @par Example * @code - $ export TDM_DEBUG=1 + * $ export TDM_DEBUG=1 * @endcode */ -extern int tdm_debug; - -//#define TDM_CONFIG_DLOG -//#define TDM_CONFIG_ASSERT -#undef TDM_ASSERT -#ifdef TDM_CONFIG_ASSERT -#define TDM_ASSERT(o) assert(o) -#else -#define TDM_ASSERT(o) -#endif +enum { + TDM_LOG_LEVEL_NONE, + TDM_LOG_LEVEL_ERR, + TDM_LOG_LEVEL_WRN, + TDM_LOG_LEVEL_INFO, + TDM_LOG_LEVEL_DBG, +}; -#ifdef TDM_CONFIG_DLOG +void tdm_log_enable_color(unsigned int enable); +void tdm_log_enable_dlog(unsigned int enable); +void tdm_log_set_debug_level(int level); +void tdm_log_set_assert_level(int level); +void tdm_log_set_path(const char *path); +void tdm_log_printf(int level, const char *fmt, ...); +void tdm_log_print(int level, const char *fmt, ...); -#include +void tdm_log_reset(void); -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "TDM" +extern unsigned int tdm_log_debug_level; #define TDM_DBG(fmt, args...) \ - if (tdm_debug) \ do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - LOGD("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ - printf("[TDM_DBG][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); - + if (tdm_log_debug_level >= TDM_LOG_LEVEL_DBG) { \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + tdm_log_print(TDM_LOG_LEVEL_DBG, "[%5d.%06d][%d][%s %d]"fmt, \ + (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \ + (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \ + } \ + } while (0) #define TDM_INFO(fmt, args...) \ do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - LOGI("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ - printf("[TDM_INF][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); - + if (tdm_log_debug_level >= TDM_LOG_LEVEL_INFO) { \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + tdm_log_print(TDM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt, \ + (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \ + (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \ + } \ + } while (0) #define TDM_WRN(fmt, args...) \ do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - LOGI("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ - printf("[TDM_WRN][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); - + if (tdm_log_debug_level >= TDM_LOG_LEVEL_WRN) { \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + tdm_log_print(TDM_LOG_LEVEL_WRN, "[%5d.%06d][%d][%s %d]"fmt, \ + (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \ + (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \ + } \ + } while (0) #define TDM_ERR(fmt, args...) \ do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - LOGE("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ - printf("[TDM_ERR][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); - -#else /* TDM_CONFIG_DLOG */ - -#include - -#define COLOR_RED "\x1b[31m" /* for error */ -#define COLOR_YELLOW "\x1b[33m" /* for warning */ -#define COLOR_GREEN "\x1b[32m" /* for info */ -#define COLOR_RESET "\x1b[0m" - -#define TDM_DBG(fmt, args...) \ - if (tdm_debug) \ - do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - printf("[TDM_DBG][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); - -#define TDM_INFO(fmt, args...) \ - do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - printf(COLOR_GREEN"[TDM_INF]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); - -#define TDM_WRN(fmt, args...) \ + if (tdm_log_debug_level >= TDM_LOG_LEVEL_ERR) { \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + tdm_log_print(TDM_LOG_LEVEL_ERR, "[%5d.%06d][%d][%s %d]"fmt, \ + (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \ + (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \ + } \ + } while (0) + +#define TDM_NEVER_GET_HERE() TDM_WRN("** NEVER GET HERE **") +#define TDM_DEPRECATED(str) \ do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - printf(COLOR_YELLOW"[TDM_WRN]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - TDM_ASSERT(0); \ - } while (0); - -#define TDM_ERR(fmt, args...) \ - do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - printf(COLOR_RED"[TDM_ERR]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - TDM_ASSERT(0); \ - } while (0); - -#endif /* TDM_CONFIG_DLOG */ + if (str) \ + TDM_WRN("** DEPRECATED: %s **", str); \ + else \ + TDM_WRN("** DEPRECATED **"); \ + } while(0) #ifdef __cplusplus }