Revert "edc: indicator paddings and scover code removed."
[apps/core/preloaded/indicator-win.git] / inc / log.h
1 /*
2  * Samsung API
3  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  * http://www.apache.org/license/
10  *
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.
16  */
17
18 #ifndef __SAMPLE_APP_LOG_H__
19 #define __SAMPLE_APP_LOG_H__
20
21 #include <unistd.h>
22 #include <dlog.h>
23 #include <string.h>
24
25 #undef LOG_TAG
26 #define LOG_TAG "INDICATOR"
27
28 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
29
30 #if !defined(_D)
31 #define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s[%d] " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg)
32 #endif
33
34 #if !defined(_W)
35 #define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s[%d] " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg)
36 #endif
37
38 #if !defined(_E)
39 #define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s[%d] " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg)
40 #endif
41
42 #define retvm_if(expr, val, fmt, arg...) do { \
43         if(expr) { \
44                 _E(fmt, ##arg); \
45                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
46                 return val; \
47         } \
48 } while (0)
49
50 #define retv_if(expr, val) do { \
51         if(expr) { \
52                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
53                 return (val); \
54         } \
55 } while (0)
56
57 #define retm_if(expr, fmt, arg...) do { \
58         if(expr) { \
59                 _E(fmt, ##arg); \
60                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
61                 return; \
62         } \
63 } while (0)
64
65 #define ret_if(expr) do { \
66         if(expr) { \
67                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
68                 return; \
69         } \
70 } while (0)
71
72 #define goto_if(expr, val) do { \
73         if(expr) { \
74                 _E("(%s) -> goto", #expr); \
75                 goto val; \
76         } \
77 } while (0)
78
79 #define break_if(expr) { \
80         if(expr) { \
81                 _E("(%s) -> break", #expr); \
82                 break; \
83         } \
84 }
85
86 #define continue_if(expr) { \
87         if(expr) { \
88                 _E("(%s) -> continue", #expr); \
89                 continue; \
90         } \
91 }
92
93 #endif /* __SAMPLE_APP_LOG_H__ */