Adjust coding rules
[platform/core/api/application.git] / include / app_preference_log.h
1 /*
2  * Copyright (c) 2015 - 2016 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 #ifdef LOG_TAG
18 #undef LOG_TAG
19 #endif
20
21 #define LOG_TAG "CAPI_APPFW_APPLICATION_PREFERENCE"
22 #define DBG_MODE (1)
23
24 #ifndef __PREFERENCE_LOG_H__
25 #define __PREFERENCE_LOG_H__
26
27 #include <stdio.h>
28 #include <unistd.h>
29 #include <stdlib.h>
30 #include <dlog.h>
31
32
33 #define INFO(fmt, arg...)
34 #define DBG(fmt, arg...) SECURE_SLOGI(fmt, ##arg)
35 #define ERR(fmt, arg...) LOGE(fmt, ##arg)
36 #define SECURE_ERR(fmt, arg...) SECURE_SLOGE(fmt, ##arg)
37 #define FATAL(fmt, arg...) SECURE_SLOGF(fmt, ##arg)
38 #define WARN(fmt, arg...) SECURE_SLOGW(fmt, ##arg)
39
40
41 /************** Return ***************/
42 #define ret_if(expr) \
43         do { \
44                 if (expr) { \
45                         ERR("(%s) -> %s() return", #expr, __FUNCTION__); \
46                         return; \
47                 } \
48         } while (0)
49 #define retv_if(expr, val) \
50         do { \
51                 if (expr) { \
52                         ERR("(%s) -> %s() return", #expr, __FUNCTION__); \
53                         return (val); \
54                 } \
55         } while (0)
56 #define retm_if(expr, fmt, arg...) \
57         do { \
58                 if (expr) { \
59                         ERR(fmt, ##arg); \
60                         return; \
61                 } \
62         } while (0)
63 #define retvm_if(expr, val, fmt, arg...) \
64         do { \
65                 if (expr) { \
66                         ERR(fmt, ##arg); \
67                         return (val); \
68                 } \
69         } while (0)
70 #define retex_if(expr, fmt, arg...) \
71         do { \
72                 if (expr) { \
73                         ERR(fmt, ##arg); \
74                         goto CATCH; \
75                 } \
76         } while (0)
77
78
79 /************** TimeCheck ***************/
80 #ifdef PREFERENCE_TIMECHECK
81 #define START_TIME_CHECK \
82         init_time();\
83         startT = set_start_time();
84 #define END_TIME_CHECK \
85         PREFERENCE_DEBUG("time = %f ms\n", exec_time(startT));
86 #else
87 #define START_TIME_CHECK
88 #define END_TIME_CHECK
89 #endif
90
91
92 #endif                          /* __PREFERENCE_LOG_H__ */
93