3 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
24 #if defined(ENABLE_DLOG_OUT)
25 #define LOG_TAG "DEVICED"
27 #define DLOG_ERR DLOG_ERROR
28 #define __LOG(prio, fmt, arg...) \
29 do { SLOG(prio, LOG_TAG, fmt, ##arg); } while (0)
30 #define __LOGD(prio, fmt, arg...) \
31 do { SLOG(prio, LOG_TAG, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); } while (0)
32 #define __PRT(prio, fmt, arg...) \
33 do { fprintf(((D##prio) == DLOG_ERR ? stderr : stdout), fmt"\n", ##arg); } while (0)
34 #define __PRTD(prio, fmt, arg...) \
36 fprintf(((D##prio) == DLOG_ERR ? stderr : stdout), \
37 "%s: %s(%d) > "fmt"\n", __MODULE__, __func__, __LINE__, ##arg); \
41 #define __LOG(prio, fmt, arg...) \
42 do { syslog(prio, fmt, ##arg); } while (0)
43 #define __LOGD(prio, fmt, arg...) \
44 do { syslog(prio, "%s: %s(%d) > "fmt"\n", __MODULE__, __func__, __LINE__, ##arg); } while (0)
45 #define __PRT(prio, fmt, arg...) \
46 do { fprintf(((prio) == LOG_ERR ? stderr : stdout), fmt"\n", ##arg); } while (0)
47 #define __PRTD(prio, fmt, arg...) \
49 fprintf(((prio) == LOG_ERR ? stderr : stdout), \
50 "%s: %s(%d) > "fmt"\n", __MODULE__, __func__, __LINE__, ##arg); \
55 extern int g_trace_depth;
56 #define __PRT_TRACE(prio, fmt, arg...) \
57 do { __LOGD(prio, fmt, ##arg); } while (0)
60 for(___i=0;___i<g_trace_depth;___i++)\
62 fprintf(stdout, " "); \
65 "[%s:%d] "fmt"\n", __FUNCTION__, __LINE__,##arg); \
66 __LOGD(prio, fmt, ##arg); \
68 #define __PRT_TRACE_ERR(prio, fmt, arg...) \
69 do { __LOGD(prio, fmt, ##arg); } while (0)
72 for(___i=0;___i<g_trace_depth;___i++)\
74 fprintf(stdout, " "); \
77 "%c[1;31m[%s:%d] "fmt"%c[0m\n",27, __FUNCTION__, __LINE__,##arg,27); \
78 __LOGD(prio, fmt, ##arg); \
80 #define __PRT_TRACE_EM(prio, fmt, arg...) \
81 do { __LOGD(prio, fmt, ##arg); } while (0)
84 for(___i=0;___i<g_trace_depth;___i++)\
86 fprintf(stdout, " "); \
89 "%c[1;34m[%s:%d] "fmt"%c[0m\n",27, __FUNCTION__, __LINE__,##arg,27); \
90 __LOGD(prio, fmt, ##arg); \
94 #define _NOUT(prio, fmt, arg...) do { } while (0)
101 # define _PRT_TRACE __PRT_TRACE
102 # define _PRT_TRACE_ERR __PRT_TRACE_ERR
103 # define _PRT_TRACE_EM __PRT_TRACE_EM
109 # define _PRT_TRACE _NOUT
110 # define _PRT_TRACE_ERR _NOUT
111 # define _PRT_TRACE_EM _NOUT
114 #define PRT_INFO(fmt, arg...) _PRT(LOG_INFO, fmt, ##arg)
115 #define PRT_ERR(fmt, arg...) _PRT(LOG_ERR, fmt, ##arg)
116 #define PRT_DBG(fmt, arg...) _PRTD(LOG_DEBUG, fmt, ##arg)
117 #define PRT_TRACE(fmt, arg...) _PRT_TRACE(LOG_DEBUG, fmt, ##arg)
118 #define PRT_TRACE_ERR(fmt, arg...) _PRT_TRACE_ERR(LOG_ERR, fmt, ##arg)
119 #define PRT_TRACE_EM(fmt, arg...) _PRT_TRACE_EM(LOG_DEBUG, fmt, ##arg)
121 #if defined(SYSLOG_OUT)
122 # define SYSLOG_INFO(fmt, arg...) _LOG(LOG_INFO, fmt, ##arg)
123 # define SYSLOG_ERR(fmt, arg...) _LOG(LOG_ERR, fmt, ##arg)
124 # define SYSLOG_DBG(fmt, arg...) _LOGD(LOG_DEBUG, fmt, ##arg)
125 # define INFO SYSLOG_INFO
126 # define ERR SYSLOG_ERR
127 # define DBG SYSLOG_DBG
128 #elif defined(ENABLE_DLOG_OUT)
133 # define INFO PRT_INFO