6dcdfb89403cfcdfd74b37e64a270e3274ed6d2f
[apps/core/preloaded/lockscreen.git] / include / log.h
1 /*
2  * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 #ifndef __LOG_H__
18 #define __LOG_H__
19
20 #include <dlog.h>
21 #include <app_i18n.h>
22
23 #ifdef LOG_TAG
24         #undef LOG_TAG
25 #endif
26
27 #define LOG_TAG "LOCKSCREEN"
28 #define ENABLE_LOG_SYSTEM
29
30 #ifdef ENABLE_LOG_SYSTEM
31         #define _E(fmt, arg...)  LOGE("[%s:%d:E] "fmt,  __func__, __LINE__, ##arg)
32         #define _D(fmt, arg...)  LOGD("[%s:%d:D] "fmt,  __func__, __LINE__, ##arg)
33         #define _W(fmt, arg...) LOGW("[%s:%d:W] "fmt,  __func__, __LINE__, ##arg)
34         #define _I(fmt, arg...) LOGI("[%s:%d:I] "fmt,  __func__, __LINE__, ##arg)
35         #define _SECURE_E(fmt, arg...)  SECURE_LOGE("["LOG_TAG"%s:%d:E] : %s "fmt, __FILE__, __LINE__, __func__, ##arg)
36         #define _SECURE_D(fmt, arg...)  SECURE_LOGD("["LOG_TAG"%s:%d:D] : %s "fmt, __FILE__, __LINE__, __func__, ##arg)
37         #define _SECURE_W(fmt, arg...) SECURE_LOGW("["LOG_TAG"%s:%d:W] : %s "fmt, __FILE__, __LINE__, __func__, ##arg)
38         #define _SECURE_I(fmt, arg...) SECURE_LOGI("["LOG_TAG"%s:%d:I] : %s "fmt, __FILE__, __LINE__, __func__, ##arg)
39 #else
40         #define _E(fmt, arg...)
41         #define _D(fmt, arg...)
42         #define _W(fmt, arg...)
43         #define _I(fmt, arg...)
44         #define _SECURE_E(fmt, arg...)
45         #define _SECURE_D(fmt, arg...)
46         #define _SECURE_W(fmt, arg...)
47         #define _SECURE_I(fmt, arg...)
48 #endif
49
50 #undef _
51 #define _(str) i18n_get_text(str)
52
53 #define retv_if(expr, val) do { \
54         if(expr) { \
55                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
56                 return (val); \
57         } \
58 } while (0)
59
60 #define retm_if(expr, fmt, arg...) do { \
61         if(expr) { \
62                 _E(fmt, ##arg); \
63                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
64                 return; \
65         } \
66 } while (0)
67
68 #define ret_if(expr) do { \
69         if(expr) { \
70                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
71                 return; \
72         } \
73 } while (0)
74
75 #define goto_if(expr, val) do { \
76         if(expr) { \
77                 _E("(%s) -> goto", #expr); \
78                 goto val; \
79         } \
80 } while (0)
81
82 #define break_if(expr) { \
83         if(expr) { \
84                 _E("(%s) -> break", #expr); \
85                 break; \
86         } \
87 }
88
89 #define continue_if(expr) { \
90         if(expr) { \
91                 _E("(%s) -> continue", #expr); \
92                 continue; \
93         } \
94 }
95
96 #endif