Fix coverity issue 1149129
[apps/native/volume-app.git] / inc / _util_log.h
1 /*
2  * Copyright (c) 2009-2015 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
18 #ifndef __VOLUME_UTIL_LOG_H__
19 #define __VOLUME_UTIL_LOG_H__
20
21 #include <unistd.h>
22 #include <dlog.h>
23
24 #undef LOG_TAG
25 #define LOG_TAG "VOLUME"
26
27 #ifndef __MODULE__
28 #define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
29 #endif
30
31 #define LOG_V(prio, tag, fmt, arg...) \
32         ({ do { \
33                 dlog_print(prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg);\
34         } while (0); })
35
36 #define _D(format, arg...) LOG_V(DLOG_DEBUG, LOG_TAG, format, ##arg)
37 #define _I(format, arg...) LOG_V(DLOG_INFO, LOG_TAG, format, ##arg)
38 #define _W(format, arg...) LOG_V(DLOG_WARN, LOG_TAG, format, ##arg)
39 #define _E(format, arg...) LOG_V(DLOG_ERROR, LOG_TAG, format, ##arg)
40 #define _F(format, arg...) LOG_V(DLOG_FATAL, LOG_TAG, format, ##arg)
41
42 #define _SECURE_E(fmt, arg...) SECURE_LOGE("[%s:%d] "fmt, __FUNCTION__, __LINE__, ##arg)
43 #define _SECURE_D(fmt, arg...) SECURE_LOGD("[%s:%d] "fmt, __FUNCTION__, __LINE__, ##arg)
44
45 #define retvm_if_timer(timer, expr, val, fmt, arg...) do { \
46         if (expr) { \
47                 _E(fmt, ##arg); \
48                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
49                 timer = NULL; \
50                 return (val); \
51         } \
52 } while (0)
53
54 #define retvm_if(expr, val, fmt, arg...) do { \
55         if (expr) { \
56                 _E(fmt, ##arg); \
57                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
58                 return (val); \
59         } \
60 } while (0)
61
62 #define retv_if(expr, val) do { \
63         if (expr) { \
64                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
65                 return (val); \
66         } \
67 } while (0)
68
69 #define retm_if(expr, fmt, arg...) do { \
70         if (expr) { \
71                 _E(fmt, ##arg); \
72                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
73                 return; \
74         } \
75 } while (0)
76
77 #define ret_if(expr) do { \
78         if (expr) { \
79                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
80                 return; \
81         } \
82 } while (0)
83
84 #endif                          /* __VOLUME_UTIL_LOG_H__ */