Modify to exit immediately after init failed
[apps/native/ttsd-worker-package.git] / inc / log.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (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 #ifndef __PACKAGE_WORKER_LOG_H__
18 #define __PACKAGE_WORKER_LOG_H__
19
20 #include <dlog.h>
21
22 #ifdef  LOG_TAG
23 #undef  LOG_TAG
24 #endif
25 #define LOG_TAG "TTSD_PACKAGE"
26
27 #if !defined(_V)
28 #define _V(fmt, arg...) dlog_print(DLOG_VERBOSE, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
29 #endif
30
31 #if !defined(_D)
32 #define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
33 #endif
34
35 #if !defined(_I)
36 #define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
37 #endif
38
39 #if !defined(_W)
40 #define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
41 #endif
42
43 #if !defined(_E)
44 #define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
45 #endif
46
47 #define retvm_if(expr, val, fmt, arg...) do { \
48         if (expr) { \
49                 _E(fmt, ##arg); \
50                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
51                 return val; \
52         } \
53 } while (0)
54
55 #define retv_if(expr, val) do { \
56         if (expr) { \
57                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
58                 return (val); \
59         } \
60 } while (0)
61
62 #define retm_if(expr, fmt, arg...) do { \
63         if (expr) { \
64                 _E(fmt, ##arg); \
65                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
66                 return; \
67         } \
68 } while (0)
69
70 #define ret_if(expr) do { \
71         if (expr) { \
72                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
73                 return; \
74         } \
75 } while (0)
76
77 #define goto_if(expr, val) do { \
78         if (expr) { \
79                 _E("(%s) -> goto", #expr); \
80                 goto val; \
81         } \
82 } while (0)
83
84 #define break_if(expr) { \
85         if (expr) { \
86                 _E("(%s) -> break", #expr); \
87                 break; \
88         } \
89 }
90
91 #define continue_if(expr) { \
92         if (expr) { \
93                 _E("(%s) -> continue", #expr); \
94                 continue; \
95         } \
96 }
97
98 #endif /* __PACKAGE_WORKER_LOG_H__*/