/* * * Copyright 2012 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 __DB_DLOG_H__ #define __DB_DLOG_H__ #include #include #include /********************************************************************** ******************define, struct ,typedef, union, enum, global val ************************************* ***********************************************************************/ #define DB_FUN_BEG() DB_INFO("====>>>>fun=%s, BEGIN====>>>>", __FUNCTION__); #define DB_FUN_END() DB_INFO("====>>>>fun=%s, END====>>>>", __FUNCTION__); #define DB_INFO(fmt, arg...) LOGD("[%s:%d] "fmt, __FILE__, __LINE__, ##arg); #define DB_ERR(fmt, arg...) LOGE(FONT_COLOR_RED"[%s:%d] "fmt FONT_COLOR_RESET, __FILE__, __LINE__, ##arg); #define DB_FUN_DEBUG_BEG() //DB_INFO("====>>>>fun=%s, BEGIN====>>>>",__FUNCTION__); #define DB_FUN_DEBUG_END() //DB_INFO("====>>>>fun=%s, END====>>>>", __FUNCTION__); #define DB_DEBUG_INFO(fmt, arg...) //DB_INFO(fmt, ##arg) #define DB_DEBUG_INFO(fmt, arg...) //DB_ERR(fmt,##arg) #define DB_RET_IF(expr) \ do { \ if (expr) {\ nErr = FAILED;\ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } \ } while (1); #define DB_RETV_IF(expr, val) \ do { \ if (expr) { \ nErr = FAILED;\ ret = val;\ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } while (0); #define DB_RETE_IF(expr, errorId) \ do { \ if (expr) { \ nErr = errorId;\ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } while (0); #define DB_RETEM_IF(expr, errorId, fmt, arg...) \ do { \ if (expr) { \ nErr = errorId;\ DB_INFO_RED(fmt, ##arg); \ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } while (0); #define DB_RETVE_IF(expr, val, errorId) \ do { \ if (expr) { \ nErr = errorId;\ ret = val;\ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } while (0); #define DB_RETM_IF(expr, fmt, arg...) \ do { \ if (expr) { \ nErr = FAILED;\ DB_INFO_RED(fmt, ##arg); \ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } while (0); #define DB_RETVM_IF(expr, val, fmt, arg...) \ do { \ if (expr) { \ nErr = FAILED;\ ret = val;\ DB_INFO_RED(fmt, ##arg); \ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } while (0); #define DB_RETVME_IF(expr, val, errorId, fmt, arg...) \ do { \ if (expr) { \ nErr = errorId;\ ret = val;\ DB_INFO_RED(fmt, ##arg); \ DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \ goto End; \ } \ } while (0); /* anci c color type */ #define FONT_COLOR_RESET "\033[0m" #define FONT_COLOR_RED "\033[31m" #define FONT_COLOR_GREEN "\033[32m" #define FONT_COLOR_YELLOW "\033[33m" #define FONT_COLOR_BLUE "\033[34m" #define FONT_COLOR_PURPLE "\033[35m" #define FONT_COLOR_CYAN "\033[36m" #define FONT_COLOR_GRAY "\033[37m" #define DB_INFO_RED(fmt, arg...) DB_INFO(FONT_COLOR_RED fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_GREEN(fmt, arg...) DB_INFO(FONT_COLOR_GREEN fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_YELLOW(fmt, arg...) DB_INFO(FONT_COLOR_YELLOW fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_BLUE(fmt, arg...) DB_INFO(FONT_COLOR_BLUE fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_PURPLE(fmt, arg...) DB_INFO(FONT_COLOR_PURPLE fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_GREEN(fmt, arg...) DB_INFO(FONT_COLOR_GREEN fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_CYAN(fmt, arg...) DB_INFO(FONT_COLOR_CYAN fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_GRAY(fmt, arg...) DB_INFO(FONT_COLOR_GRAY fmt FONT_COLOR_RESET, ##arg) #define DB_INFO_WITH_COLOR(color, fmt, arg...) DB_INFO(color fmt FONT_COLOR_RESET, ##arg) // #define warn_if(expr, fmt, arg...) do { \ if (expr) { \ DB_INFO("(%s) -> "fmt, #expr, ##arg); \ } \ } while (0) #define ret_if(expr) do { \ if (expr) { \ DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ return; \ } \ } while (0) #define retv_if(expr, val) do { \ if (expr) { \ DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ return (val); \ } \ } while (0) #define retm_if(expr, fmt, arg...) do { \ if (expr) { \ DB_ERR(fmt, ##arg); \ DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ return; \ } \ } while (0) #define retvm_if(expr, val, fmt, arg...) do { \ if (expr) { \ DB_ERR(fmt, ##arg); \ DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ return (val); \ } \ } while (0) #endif //__DB_DLOG_H__