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__
45 #define XLOG_MASK_LOGLEVEL 0x000000FF
46 #define XLOG_MASK_OPTIONS 0xFFFFFF00
57 XLOG_LEVEL_DEFAULT = XLOG_LEVEL_3
60 #define XLOG_LEVEL_DEBUG XLOG_LEVEL_0
61 #define XLOG_LEVEL_TRACE XLOG_LEVEL_1
62 #define XLOG_LEVEL_INFO XLOG_LEVEL_2
63 #define XLOG_LEVEL_WARNING XLOG_LEVEL_3
64 #define XLOG_LEVEL_ERROR XLOG_LEVEL_4
67 #define XLOG_OPTION_KLOG (1 << 8)
68 #define XLOG_OPTION_SLOG (1 << 9)
69 #define XLOG_OPTION_XORG (1 << 10)
70 #define XLOG_OPTION_SECURE (1 << 11) /* print secure log */
78 int xDbgLogEnumModules (LOG_ENUM_MODE mode, char *buf, int *remain);
79 int xDbgLogSetLevel (unsigned int module, int level);
80 void* xDbgLog (unsigned int module, int logoption, const char *file, int line, const char *f, ...);
83 #define XLOG_DEBUG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_DEBUG, __FILE__, __LINE__, ##ARG)
84 #define XLOG_TRACE(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_TRACE, __FILE__, __LINE__, ##ARG)
85 #define XLOG_INFO(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO, __FILE__, __LINE__, ##ARG)
86 #define XLOG_WARNING(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_WARNING, __FILE__, __LINE__, ##ARG)
87 #define XLOG_ERROR(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_ERROR, __FILE__, __LINE__, ##ARG)
88 #define XLOG_KLOG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO|XLOG_OPTION_KLOG, __FILE__, __LINE__, ##ARG)
89 #define XLOG_SLOG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO|XLOG_OPTION_SLOG, __FILE__, __LINE__, ##ARG)
90 #define XLOG_XORG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO|XLOG_OPTION_XORG, __FILE__, __LINE__, ##ARG)
91 #define XLOG_SECURE(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO|XLOG_OPTION_SECURE, __FILE__, __LINE__, ##ARG)
93 #define XDBG_DEBUG(mod, fmt, ARG...) XLOG_DEBUG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
94 #define XDBG_TRACE(mod, fmt, ARG...) XLOG_TRACE(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
95 #define XDBG_INFO(mod, fmt, ARG...) XLOG_INFO(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
96 #define XDBG_WARNING(mod, fmt, ARG...) XLOG_WARNING(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
97 #define XDBG_ERROR(mod, fmt, ARG...) XLOG_ERROR(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
98 #define XDBG_ERRNO(mod, fmt, ARG...) XLOG_ERROR(mod, "[%s](err=%s(%d)) "fmt, __FUNCTION__, strerror(errno), errno, ##ARG)
99 #define XDBG_KLOG(mod, fmt, ARG...) XLOG_KLOG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
100 #define XDBG_SLOG(mod, fmt, ARG...) XLOG_SLOG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
101 #define XDBG_XORG(mod, fmt, ARG...) XLOG_XORG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
103 /* _SECURE_LOG defined by system, <dlog.h> */
105 #define XDBG_SECURE(mod, fmt, ARG...) XLOG_SECURE(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
107 #define XDBG_SECURE(mod, fmt, ARG...) (0)
110 #define XDBG_NEVER_GET_HERE(mod) XLOG_ERROR(mod, "[%s:%d] ** NEVER GET HERE **\n", __FUNCTION__,__LINE__)
112 #define XDBG_WARNING_IF_FAIL(cond) {if (!(cond)) { ErrorF ("[%s] '%s' failed.\n", __FUNCTION__, #cond);}}
113 #define XDBG_RETURN_IF_FAIL(cond) {if (!(cond)) { ErrorF ("[%s] '%s' failed.\n", __FUNCTION__, #cond); return; }}
114 #define XDBG_RETURN_VAL_IF_FAIL(cond, val) {if (!(cond)) { ErrorF ("[%s] '%s' failed.\n", __FUNCTION__, #cond); return val; }}
115 #define XDBG_RETURN_VAL_IF_ERRNO(cond, val, errno) {if (!(cond)) { ErrorF ("[%s] '%s' failed. (err=%s(%d))\n", __FUNCTION__, #cond, strerror(errno), errno); return val; }}
116 #define XDBG_GOTO_IF_FAIL(cond, dst) {if (!(cond)) { ErrorF ("[%s] '%s' failed.\n", __FUNCTION__, #cond); goto dst; }}
117 #define XDBG_GOTO_IF_ERRNO(cond, dst, errno) {if (!(cond)) { ErrorF ("[%s] '%s' failed. (err=%s(%d))\n", __FUNCTION__, #cond, strerror(errno), errno); goto dst; }}
119 #define XDBG_REPLY(fmt, ARG...) \
121 if (reply && len && *len > 0) \
123 int s = snprintf (reply, *len, fmt, ##ARG); \
129 unsigned int xDbgLogGetModule (char *name);
131 #define _C(b,s) (((b) >> (s)) & 0xFF)
132 #define _B(c,s) ((((unsigned int)(c)) & 0xff) << (s))
133 #define XDBG_M(a,b,c,d) (_B(d,24)|_B(c,16)|_B(b,8)|_B(a,0))
135 /* debug module for XDBG */
136 #define MXDBG XDBG_M('X','D','B','G')
138 #endif /* __XDBG_LOG_H__ */