tizen 2.4 release
[framework/uifw/libeom.git] / src / eom-log.h
1 /**************************************************************************
2
3 eom (external output manager)
4
5 Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved.
6
7 Contact:
8 SooChan Lim <sc1.lim@samsung.com>
9 Boram Park <boram1288.park@samsung.com>
10 Changyeon Lee <cyeon.lee@samsung.com>
11
12 Permission is hereby granted, free of charge, to any person obtaining a
13 copy of this software and associated documentation files (the
14 "Software"), to deal in the Software without restriction, including
15 without limitation the rights to use, copy, modify, merge, publish,
16 distribute, sub license, and/or sell copies of the Software, and to
17 permit persons to whom the Software is furnished to do so, subject to
18 the following conditions:
19
20 The above copyright notice and this permission notice (including the
21 next paragraph) shall be included in all copies or substantial portions
22 of the Software.
23
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
27 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
28 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
32 **************************************************************************/
33
34 #ifndef __EOM_LOG_H__
35 #define __EOM_LOG_H__
36
37 #include <config.h>
38 #include <stdio.h>
39 #include <unistd.h>
40 #include <stdlib.h>
41
42 #ifndef API
43 #define API __attribute__ ((visibility("default")))
44 #endif
45
46 #undef HAVE_DLOG
47
48 extern bool eom_debug_on;
49
50 #ifndef HAVE_CAPI_0_1_1
51 static inline void set_last_result(int i) {; }
52 #endif
53
54 #ifdef HAVE_DLOG
55 #define LOG_TAG "EOM"
56 #include <dlog.h>
57 #define INFO(fmt, arg...)  \
58         if (eom_debug_on) SECURE_SLOGI(fmt, ##arg)
59 #define WARN(fmt, arg...)  \
60         if (eom_debug_on) SECURE_SLOGW(fmt, ##arg)
61 #define ERR(fmt, arg...)   SECURE_SLOGE(fmt, ##arg)
62 #define FATAL(fmt, arg...) SECURE_SLOGF(fmt, ##arg)
63 #else   /* HAVE_DLOG */
64 #include <stdlib.h>
65 #define INFO(fmt, arg...)  \
66         if (eom_debug_on) fprintf(stdout, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
67 #define WARN(fmt, arg...)  \
68         if (eom_debug_on) fprintf(stderr, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
69 #define ERR(fmt, arg...)   fprintf(stderr, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
70 #define FATAL(fmt, arg...) fprintf(stderr, "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
71 #endif   /* HAVE_DLOG */
72
73 #define WARN_IF_FAIL(cond)                              if (!(cond)) ERR("'%s' failed", #cond);
74 #define RET_IF_FAIL(cond)                               {if (!(cond)) { ERR("'%s' failed", #cond); return; } }
75 #define RETV_IF_FAIL(cond, val)                 {if (!(cond)) { ERR("'%s' failed", #cond); return val; } }
76 #define GOTO_IF_FAIL(cond, dst)                 {if (!(cond)) { ERR("'%s' failed", #cond); goto dst; } }
77 #define NEVER_GET_HERE()                                ERR("** NEVER GET HERE **\n")
78
79 #endif  /* __EOM_LOG_H__ */