1 /**************************************************************************
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
7 Contact: Boram Park <boram1288.park@samsung.com>
8 Sangjin LEE <lsj119@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
32 #if defined(XDBG_CLIENT)
33 #error "This header is not for client."
36 #ifndef __XDBG_LOG_H__
37 #define __XDBG_LOG_H__
42 #include <xdbg_log_secure.h>
44 unsigned int xDbgLogGetModule (char *name);
45 Bool xDbgGetLogEnableDlog ();
47 #define _C(b,s) (((b) >> (s)) & 0xFF)
48 #define _B(c,s) ((((unsigned int)(c)) & 0xff) << (s))
49 #define XDBG_M(a,b,c,d) (_B(d,24)|_B(c,16)|_B(b,8)|_B(a,0))
51 /* debug module for XDBG */
52 #define MXDBG XDBG_M('X','D','B','G')
55 #define XLOG_MASK_LOGLEVEL 0x000000FF
56 #define XLOG_MASK_OPTIONS 0xFFFFFF00
67 XLOG_LEVEL_DEFAULT = XLOG_LEVEL_2,
70 #define XDBG_ALL_MODULE 0xFFFFFFFF
72 #define XLOG_LEVEL_DEBUG XLOG_LEVEL_0 /* console */
73 #define XLOG_LEVEL_TRACE XLOG_LEVEL_1 /* console */
74 #define XLOG_LEVEL_INFO XLOG_LEVEL_2 /* Xorg.0.log or dlog */
75 #define XLOG_LEVEL_WARNING XLOG_LEVEL_3 /* Xorg.0.log and dlog */
76 #define XLOG_LEVEL_ERROR XLOG_LEVEL_4 /* Xorg.0.log and dlog */
78 #define XLOG_OPTION_KLOG (1 << 8) /* LV:WARNING and /dev/kmsg */
79 #define XLOG_OPTION_SECURE (1 << 12) /* LV:INFO. Disable when released */
87 int xDbgLogEnumModules (LOG_ENUM_MODE mode, char *buf, int *remain);
88 int xDbgLogSetLevel (unsigned int module, int level);
89 void xDbgLogEnableDlog (Bool enable);
90 void* xDbgLog (unsigned int module, int logoption, const char *file, int line, const char *f, ...);
93 #define XLOG_DEBUG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_DEBUG, __FILE__, __LINE__, ##ARG)
94 #define XLOG_TRACE(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_TRACE, __FILE__, __LINE__, ##ARG)
95 #define XLOG_INFO(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO, __FILE__, __LINE__, ##ARG)
96 #define XLOG_WARNING(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_WARNING, __FILE__, __LINE__, ##ARG)
97 #define XLOG_ERROR(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_ERROR, __FILE__, __LINE__, ##ARG)
98 #define XLOG_KLOG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_WARNING|XLOG_OPTION_KLOG, __FILE__, __LINE__, ##ARG)
99 #define XLOG_SECURE(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO|XLOG_OPTION_SECURE, __FILE__, __LINE__, ##ARG)
101 #define XDBG_DEBUG(mod, fmt, ARG...) XLOG_DEBUG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
102 #define XDBG_TRACE(mod, fmt, ARG...) XLOG_TRACE(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
103 #define XDBG_INFO(mod, fmt, ARG...) XLOG_INFO(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
104 #define XDBG_WARNING(mod, fmt, ARG...) XLOG_WARNING(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
105 #define XDBG_ERROR(mod, fmt, ARG...) XLOG_ERROR(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
106 #define XDBG_ERRNO(mod, fmt, ARG...) XLOG_ERROR(mod, "[%s](err=%s(%d)) "fmt, __FUNCTION__, strerror(errno), errno, ##ARG)
107 #define XDBG_KLOG(mod, fmt, ARG...) XLOG_KLOG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
109 #if TIZEN_ENGINEER_MODE
110 #define XDBG_SECURE(mod, fmt, ARG...) XLOG_SECURE(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
112 #define XDBG_SECURE(mod, fmt, ARG...) do { } while(0)
115 #define XDBG_NEVER_GET_HERE(mod) XLOG_ERROR(mod, "[%s:%d] ** NEVER GET HERE **\n", __FUNCTION__,__LINE__)
117 #define XDBG_WARNING_IF_FAIL(cond) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond);}}
118 #define XDBG_RETURN_IF_FAIL(cond) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond); return; }}
119 #define XDBG_RETURN_VAL_IF_FAIL(cond, val) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond); return val; }}
120 #define XDBG_RETURN_VAL_IF_ERRNO(cond, val, errno) {if (!(cond)) { XDBG_ERRNO (MXDBG, "'%s' failed.\n", #cond); return val; }}
121 #define XDBG_GOTO_IF_FAIL(cond, dst) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond); goto dst; }}
122 #define XDBG_GOTO_IF_ERRNO(cond, dst, errno) {if (!(cond)) { XDBG_ERRNO (MXDBG, "'%s' failed.\n", #cond); goto dst; }}
124 #define XDBG_REPLY(fmt, ARG...) \
126 if (reply && len && *len > 0) \
128 int s = snprintf (reply, *len, fmt, ##ARG); \
134 #endif /* __XDBG_LOG_H__ */