diff options
Diffstat (limited to 'include/ps_debug_util.h')
-rwxr-xr-x | include/ps_debug_util.h | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/include/ps_debug_util.h b/include/ps_debug_util.h new file mode 100755 index 0000000..9fd0e3d --- /dev/null +++ b/include/ps_debug_util.h @@ -0,0 +1,201 @@ +/* + * Copyright 2012-2013 Samsung Electronics Co., Ltd/ + * + * Licensed under the Flora License, Version 1.1 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + + + + + +#ifndef __DEF_PS_DEBUG_UTIL_H__ +#define __DEF_PS_DEBUG_UTIL_H__ + +#ifdef __ENABLE_DEBUG_UTIL + +#include <assert.h> + +#ifdef __ENABLE_PLATFORM_DEBUG + +#include <dlog.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "SEARCH" + +#define SEARCH_FUNC_START \ + do {\ + LOGD("[%s() START ----->]\n", __FUNCTION__);\ + }while(0) + +#define SEARCH_FUNC_END \ + do {\ + LOGD("[%s() <----- END]\n", __FUNCTION__);\ + }while(0) + +#define SEARCH_FUNC_LINE \ + do {\ + LOGD("[%s() \t%s:%d]\n", __FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + }while(0) + +#define SEARCH_DEBUG_LOG(fmt, arg...) \ + do {\ + LOGD("\x1b[32m[SEARCH][D][" fmt "]\x1b[0m\n", ##arg);\ + }while(0) + +#define SEARCH_DEBUG_WARNING(fmt, arg...) \ + do {\ + LOGW("\x1b[33m[SEARCH][W][" fmt "]\x1b[0m\n", ##arg);\ + }while(0) + +#define SEARCH_DEBUG_ERROR(fmt, arg...) \ + do {\ + LOGE("\x1b[31m[SEARCH][E][" fmt "]\x1b[0m\n", ##arg);\ + }while(0) + +#define SEARCH_ASSERT_IF(cond) \ + do {\ + if(cond) {\ + LOGE("\x1b[31m[%s() \t%s:%d][ASSERT]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + assert(0);\ + }\ + }while(0) + +#define SEARCH_RETV_IF(cond,ret) \ + do {\ + if(cond) {\ + LOGW("\x1b[33m[%s() \t%s:%d][RET_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + return ret;\ + }\ + }while(0) + +#define SEARCH_RETV_IF_WITH_ERRORV(cond,ret,errorv) \ + do {\ + if(cond) {\ + LOGW("\x1b[33m[%s() \t%s:%d][RET_IF]\x1b[0m error value = %d",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__, errorv);\ + return ret;\ + }\ + }while(0) + +#define SEARCH_RET_IF(cond) \ + do {\ + if(cond) {\ + LOGW("\x1b[33m[%s() \t%s:%d][RET_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + return;\ + }\ + }while(0) + +#define SEARCH_RET_IF_STR_INVALID(str,ret) \ + do {\ + if((str == NULL) || strlen(str) == 0) {\ + LOGW("\x1b[33m[%s() \t%s:%d][RET_STR_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + return ret;\ + }\ + }while(0) + +#else + +#include <stdio.h> + +#define SEARCH_FUNC_START \ + do {\ + fprintf(stderr, "[SEARCH][%s() START ----->]\n", __FUNCTION__);\ + }while(0) + +#define SEARCH_FUNC_END \ + do {\ + fprintf("[SEARCH][%s() <----- END]\n", __FUNCTION__);\ + }while(0) + +#define SEARCH_FUNC_LINE \ + do {\ + fprintf("[SEARCH][%s() \t%s:%d]\n", __FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + }while(0) + +#define SEARCH_DEBUG_LOG(fmt, arg...) \ + do {\ + fprintf(stderr, "[SEARCH][D][" fmt "\n", ##arg);\ + }while(0) + +#define SEARCH_DEBUG_WARNING(fmt, arg...) \ + do {\ + fprintf(stderr, "[SEARCH][W][" fmt "\n", ##arg);\ + }while(0) + +#define SEARCH_DEBUG_ERROR(fmt, arg...) \ + do {\ + fprintf(stderr, "[SEARCH][E][" fmt "\n", ##arg);\ + }while(0) + +#define SEARCH_ASSERT_IF(cond) \ + do {\ + if(cond) {\ + fprintf(stderr, "[%s() \t%s:%d][ASSERT]",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + assert(0);\ + }\ + }while(0) + +#define SEARCH_RETV_IF(cond,ret) \ + do {\ + if(cond) {\ + fprintf(stderr, "[%s() \t%s:%d][RET_IF]",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + return ret;\ + }\ + }while(0) + +#define SEARCH_RETV_IF_WITH_ERRORV(cond,ret,errorv) \ + do {\ + if(cond) {\ + fprintf(stderr, "[%s() \t%s:%d][RET_IF] error_value = %d",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__, errorv);\ + return ret;\ + }\ + }while(0) + +#define SEARCH_RET_IF(cond) \ + do {\ + if(cond) {\ + fprintf(stderr, "[%s() \t%s:%d][RET_IF]",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + return;\ + }\ + }while(0) + +#define SEARCH_RET_IF_STR_INVALID(str,ret) \ + do {\ + if((str == NULL) || strlen(str) == 0) {\ + fprintf("\x1b[33m[%s() \t%s:%d][RET_STR_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\ + return ret;\ + }\ + }while(0) + +#endif + +#else + +#define SEARCH_FUNC_START +#define SEARCH_FUNC_END +#define SEARCH_FUNC_LINE +#define SEARCH_DEBUG_LOG(fmt, arg...) +#define SEARCH_DEBUG_WARNING(fmt, arg...) +#define SEARCH_DEBUG_ERROR(fmt, arg...) +#define SEARCH_ASSERT_IF(cond) +#define SEARCH_RETV_IF(cond,ret) +#define SEARCH_RETV_IF_WITH_ERRORV(cond,ret,errorv) +#define SEARCH_RET_IF(cond) +#define SEARCH_RET_IF_STR_INVALID(str,ret) + +#endif // __ENABLE_DEBUG_UTIL + +#endif // __DEF_PS_DEBUG_UTIL_H__ |