Tizen 2.1 base
[apps/home/ug-myfile-efl.git] / src / include / mf-ug-dlog.h
1 /*
2  * Copyright 2012          Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *  http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18
19
20 #ifndef __DEF_MF_UG_DLOG_H_
21 #define __DEF_MF_UG_DLOG_H_
22
23 #include <stdio.h>
24 #include <string.h>
25
26 #define DLOG_ON 1
27
28 #ifdef LOG_TAG
29 #undef LOG_TAG
30 #endif
31
32 #define LOG_TAG                 "MYFILE-UG"
33 #include <dlog.h>
34
35
36 #if DLOG_ON
37 #define LOG_COLOR_RED      "\033[31m"
38 #define LOG_COLOR_RESET    "\033[0m"
39
40 #define ug_debug(fmt , args...)        LOGD("[%s][%d]debug message from ug-myfile-efl is : "fmt"\n", __func__, __LINE__, ##args)
41 #define ug_myfile_dlog(fmt , args...)        LOGD("[%s][%d]debug message from myfile is : "fmt"\n", __func__, __LINE__, ##args)
42 #define UG_TRACE_BEGIN do {\
43                 {\
44                         LOGD("\n\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
45                         __FUNCTION__, (char *)(strrchr(__FILE__, '/') + 1), __LINE__);\
46                 } \
47         } while (0);
48
49 #define UG_TRACE_END  do {\
50                 {\
51                         LOGD("\n\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
52                         __FUNCTION__, (char *)(strrchr(__FILE__, '/') + 1), __LINE__);\
53                 } \
54         } while (0);
55 #define ug_error(fmt, arg...)   LOGE(LOG_COLOR_RED"[ %s : %d]   "fmt""LOG_COLOR_RESET, __FUNCTION__, __LINE__,##arg)
56
57
58 #else
59 #define ug_myfile_dlog(fmt , args...)        printf("[MYFILE][%40s:%4d] "fmt"\n", __func__, __LINE__, ##args)
60 #endif
61 #define ug_mf_debug(fmt , args...)                      do { (void)0; } while (0)
62 #define ug_mf_warnig(fmt , args...)                     do { (void)0; } while (0)
63 #define ug_mf_error(fmt , args...)                      do { (void)0; } while (0)
64 #define UG_MYFILE_TRACE_ERROR(fmt, arg...)              do { LOGE("[%s][%d] "fmt"\n", strrchr(__FILE__, '/') + 1, __LINE__, ##arg); } while (0)
65
66 #define ug_mf_retvm_if(expr, val, fmt, arg...) do { \
67                         if (expr) { \
68                                 UG_MYFILE_TRACE_ERROR(fmt, ##arg); \
69                                 return (val); \
70                         } \
71                 } while (0)
72
73 #define ug_mf_retv_if(expr, val) do { \
74                         if (expr) { \
75                                 return (val); \
76                         } \
77                 } while (0)
78
79
80 #define ug_mf_retm_if(expr, fmt, arg...) do { \
81                         if (expr) { \
82                                 UG_MYFILE_TRACE_ERROR(fmt, ##arg); \
83                                 return; \
84                         } \
85                 } while (0)
86
87 #define MF_CHECK(expr)                          ug_mf_retm_if(!(expr),"INVALID PARAM RETURN")
88
89 #endif