4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: DongGi Jang <dg0402.jang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 * SYSLOG_INFO(), SYSLOG_ERR(), SYSLOG_DBG() are syslog() wrappers.
28 * PRT_INFO(), PRT_ERR(), PRT_DBG() are fprintf() wrappers.
30 * If SLP_DEBUG is not defined, SYSLOG_DBG() and PRT_DBG() is ignored.
32 * IF SLP_SYSLOG_OUT is defined,
33 * INFO(), ERR(), DBG() are SYSLOG_XXX()
34 * IF ENABLE_DLOG_OUT is defined,
35 * INFO(), ERR(), DBG() are SLOGI(), SLOGE(), SLOGD()
40 * warn_if(exrp, fmt, ...)
41 * If expr is true, The fmt string is printed using ERR().
43 * ret_if(), retv_if(), retm_if(), retvm_if()
44 * If expr is true, current function return.
45 * Postfix 'v' means that it has a return value and 'm' means that it has output message.
51 #if defined(ENABLE_DLOG_OUT)
52 # define LOG_TAG "DEVMAN"
56 # define __LOG(prio, fmt, arg...) \
57 do { syslog(prio, fmt, ##arg); } while (0)
58 # define __LOGD(prio, fmt, arg...) \
60 if (getenv("SLP_DEBUG")) { \
61 syslog(prio, "[%s:%d] "fmt"\n", __FILE__, __LINE__, ##arg); \
66 #define __PRTI(fmt, arg...) \
67 do { fprintf(stdout, fmt"\n", ##arg); } while (0)
68 #define __PRTE(fmt, arg...) \
69 do { fprintf(stderr, fmt"\n", ##arg); } while (0)
70 #define __PRTD(fmt, arg...) \
72 if (getenv("SLP_DEBUG")) { \
73 fprintf(stdout, "[%s:%d] "fmt"\n", __FILE__, __LINE__, ##arg); \
76 #define _NOUT(arg...) do { } while (0)
92 #define PRT_INFO(fmt, arg...) _PRTI(fmt, ##arg)
93 #define PRT_ERR(fmt, arg...) _PRTE(fmt, ##arg)
94 #define PRT_DBG(fmt, arg...) _PRTD(fmt, ##arg)
96 #if defined(SLP_SYSLOG_OUT)
97 # define SYSLOG_INFO(fmt, arg...) _LOG(LOG_INFO, fmt, ##arg)
98 # define SYSLOG_ERR(fmt, arg...) _LOG(LOG_ERR, fmt, ##arg)
99 # define SYSLOG_DBG(fmt, arg...) _LOGD(LOG_DEBUG, fmt, ##arg)
100 # define INFO SYSLOG_INFO
101 # define ERR SYSLOG_ERR
102 # define DBG SYSLOG_DBG
103 #elif defined(ENABLE_DLOG_OUT)
108 # define INFO PRT_INFO
114 # define warn_if(expr, fmt, arg...) do { \
116 DBG("(%s) -> "fmt, #expr, ##arg); \
119 # define ret_if(expr) do { \
121 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
125 # define retv_if(expr, val) do { \
127 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
131 # define retm_if(expr, fmt, arg...) do { \
134 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
138 # define retvm_if(expr, val, fmt, arg...) do { \
141 DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
147 # define warn_if(expr, fmt, arg...) do { \
152 # define ret_if(expr) do { \
157 # define retv_if(expr, val) do { \
162 # define retm_if(expr, fmt, arg...) do { \
168 # define retvm_if(expr, val, fmt, arg...) do { \
177 #endif /* __DEVLOG_H__ */