3 * Copyright (c) 2005-2008, The Android Open Source Project
4 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 * @brief This file is the header file of interface of dlog.
25 * @addtogroup CAPI_BASE_DLOG_MODULE
37 #endif /* __cplusplus */
40 * This is the local tag used for the following simplified
41 * logging macros. You can change this preprocessor definition
42 * before using the other macros to change the tag.
49 #define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
52 #ifdef TIZEN_ENGINEER_MODE
53 #ifndef TIZEN_DEBUG_ENABLE
54 #define TIZEN_DEBUG_ENABLE
59 * log priority values, in ascending priority order.
71 DLOG_PRIO_MAX /* Keep this always at the end. */
82 #define CONDITION(cond) (__builtin_expect((cond) != 0, 0))
83 #define NOP(fmt, arg...) ({ do { } while (0); })
85 // Macro inner work---------------------------------------------------------------
87 #ifdef TIZEN_DEBUG_ENABLE
88 #define LOG_(id, prio, tag, fmt, arg...) \
90 __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
93 #define LOG_(id, prio, tag, fmt, arg...) \
95 if ((int)prio != DLOG_DEBUG) { \
96 __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
102 #ifdef TIZEN_DEBUG_ENABLE
103 #define SECURE_LOG_(id, prio, tag, fmt, arg...) \
105 __dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg); \
108 #define SECURE_LOG_(id, prio, tag, fmt, arg...) NOP(fmt, ##arg)
110 // ---------------------------------------------------------------------
113 * Normally we strip Secure log from release builds.
114 * Please use this macros.
117 * For Application and etc.
118 * Simplified macro to send a main log message using the current LOG_TAG.
120 * SECURE_LOGD("app debug %d", num);
121 * SECURE_LOGE("app error %d", num);
123 #define SECURE_LOGD(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
124 #define SECURE_LOGI(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
125 #define SECURE_LOGW(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
126 #define SECURE_LOGE(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
127 #define SECURE_LOGF(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_FATAL, LOG_TAG, format, ##arg)
129 * For Framework and system etc.
130 * Simplified macro to send a system log message using the current LOG_TAG.
132 * SECURE_SLOGD("system debug %d", num);
133 * SECURE_SLOGE("system error %d", num);
135 #define SECURE_SLOGD(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
136 #define SECURE_SLOGI(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
137 #define SECURE_SLOGW(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
138 #define SECURE_SLOGE(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
139 #define SECURE_SLOGF(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_FATAL, LOG_TAG, format, ##arg)
141 * For Modem and radio etc.
142 * Simplified macro to send a radio log message using the current LOG_TAG.
144 * SECURE_RLOGD("radio debug %d", num);
145 * SECURE_RLOGE("radio error %d", num);
147 #define SECURE_RLOGD(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
148 #define SECURE_RLOGI(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
149 #define SECURE_RLOGW(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
150 #define SECURE_RLOGE(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
151 #define SECURE_RLOGF(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_FATAL, LOG_TAG, format, ##arg)
153 * For Tizen OSP Application macro.
155 #define SECURE_ALOGD(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
156 #define SECURE_ALOGI(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
157 #define SECURE_ALOGW(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
158 #define SECURE_ALOGE(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
159 #define SECURE_ALOGF(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_FATAL, LOG_TAG, format, ##arg)
161 * If you want use redefined macro.
162 * You can use this macro.
163 * This macro need priority and tag arguments.
165 #define SECURE_LOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
166 #define SECURE_SLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
167 #define SECURE_RLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
168 #define SECURE_ALOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
171 * For Application and etc.
172 * Simplified macro to send a main log message using the current LOG_TAG.
174 * LOGD("app debug %d", num);
175 * LOGE("app error %d", num);
177 #ifdef TIZEN_DEBUG_ENABLE
178 #define LOGD(format, arg...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
180 #define LOGD(format, arg...) NOP(format, ##arg)
182 #define LOGI(format, arg...) LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
183 #define LOGW(format, arg...) LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
184 #define LOGE(format, arg...) LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
185 #define LOGF(format, arg...) LOG_(LOG_ID_MAIN, DLOG_FATAL, LOG_TAG, format, ##arg)
187 * For Framework and system etc.
188 * Simplified macro to send a system log message using the current LOG_TAG.
190 * SLOGD("system debug %d", num);
191 * SLOGE("system error %d", num);
193 #ifdef TIZEN_DEBUG_ENABLE
194 #define SLOGD(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
196 #define SLOGD(format, arg...) NOP(format, ##arg)
198 #define SLOGI(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
199 #define SLOGW(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
200 #define SLOGE(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
201 #define SLOGF(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_FATAL, LOG_TAG, format, ##arg)
203 * For Modem and radio etc.
204 * Simplified macro to send a radio log message using the current LOG_TAG.
206 * RLOGD("radio debug %d", num);
207 * RLOGE("radio error %d", num);
209 #ifdef TIZEN_DEBUG_ENABLE
210 #define RLOGD(format, arg...) LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
212 #define RLOGD(format, arg...) NOP(format, ##arg)
214 #define RLOGI(format, arg...) LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
215 #define RLOGW(format, arg...) LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
216 #define RLOGE(format, arg...) LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
217 #define RLOGF(format, arg...) LOG_(LOG_ID_RADIO, DLOG_FATAL, LOG_TAG, format, ##arg)
219 * For Tizen OSP Application macro.
221 #ifdef TIZEN_DEBUG_ENABLE
222 #define ALOGD(format, arg...) LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
224 #define ALOGD(format, arg...) NOP(format, ##arg)
226 #define ALOGI(format, arg...) LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
227 #define ALOGW(format, arg...) LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
228 #define ALOGE(format, arg...) LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
229 #define ALOGF(format, arg...) LOG_(LOG_ID_APPS, DLOG_FATAL, LOG_TAG, format, ##arg)
232 * Basic log message macro that allows you to specify a priority and a tag
233 * if you want to use this macro directly, you must add this messages for unity of messages.
234 * (LOG(prio, tag, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg))
237 * #define MYMACRO(prio, tag, format, arg...) \
238 * LOG(prio, tag, format, ##arg)
240 * MYMACRO(LOG_DEBUG, MYTAG, "test mymacro %d", num);
244 #define LOG(priority, tag, format, arg...) LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
246 #define SLOG(priority, tag, format, arg...) LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
247 #define RLOG(priority, tag, format, arg...) LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
248 #define ALOG(priority, tag, format, arg...) LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
250 #define LOG_VA(priority, tag, fmt, args) \
251 vprint_log(D##priority, tag, fmt, args)
252 #define ALOG_VA(priority, tag, fmt, args) \
253 vprint_apps_log(D##priority, tag, fmt, args)
254 #define RLOG_VA(priority, tag, fmt, args) \
255 vprint_radio_log(D##priority, tag, fmt, args)
256 #define SLOG_VA(priority, tag, fmt, args) \
257 vprint_system_log(D##priority, tag, fmt, args)
258 #define print_apps_log(prio, tag, fmt...) \
259 __dlog_print(LOG_ID_APPS, prio, tag, fmt)
260 #define vprint_apps_log(prio, tag, fmt...) \
261 __dlog_vprint(LOG_ID_APPS, prio, tag, fmt)
262 #define print_log(prio, tag, fmt...) \
263 __dlog_print(LOG_ID_MAIN, prio, tag, fmt)
264 #define vprint_log(prio, tag, fmt...) \
265 __dlog_vprint(LOG_ID_MAIN, prio, tag, fmt)
266 #define print_radio_log(prio, tag, fmt...)\
267 __dlog_print(LOG_ID_RADIO, prio, tag, fmt)
268 #define vprint_radio_log(prio, tag, fmt...) \
269 __dlog_vprint(LOG_ID_RADIO, prio, tag, fmt)
270 #define print_system_log(prio, tag, fmt...)\
271 __dlog_print(LOG_ID_SYSTEM, prio, tag, fmt)
272 #define vprint_system_log(prio, tag, fmt...) \
273 __dlog_vprint(LOG_ID_SYSTEM, prio, tag, fmt)
275 // ---------------------------------------------------------------------
276 // Don't use below macro no more!! It will be removed -- Verbose and Fatal priority macro will be removed --
277 #define COMPATIBILITY_ON
278 #ifdef COMPATIBILITY_ON
281 * Don't use this macro. It's just compatibility.
282 * It will be deprecated.
284 #define LOGD_IF(cond, format, arg...) \
286 if (CONDITION(cond)) { \
287 LOGD(format, ##arg); \
290 #define LOGI_IF(cond, format, arg...) \
292 if (CONDITION(cond)) { \
293 LOGI(format, ##arg); \
296 #define LOGW_IF(cond, format, arg...) \
298 if (CONDITION(cond)) { \
299 LOGW(format, ##arg); \
302 #define LOGE_IF(cond, format, arg...) \
304 if (CONDITION(cond)) { \
305 LOGE(format, ##arg); \
308 #define LOGF_IF(cond, format, arg...) \
310 if (CONDITION(cond)) { \
311 LOGF(format, ##arg); \
314 #define SLOGD_IF(cond, format, arg...) \
316 if (CONDITION(cond)) { \
317 SLOGD(format, ##arg); \
320 #define SLOGI_IF(cond, format, arg...) \
322 if (CONDITION(cond)) { \
323 SLOGI(format, ##arg); \
326 #define SLOGW_IF(cond, format, arg...) \
328 if (CONDITION(cond)) { \
329 SLOGW(format, ##arg); \
332 #define SLOGE_IF(cond, format, arg...) \
334 if (CONDITION(cond)) { \
335 SLOGE(format, ##arg); \
338 #define SLOGF_IF(cond, format, arg...) \
340 if (CONDITION(cond)) { \
341 SLOGF(format, ##arg); \
344 #define RLOGD_IF(cond, format, arg...) \
346 if (CONDITION(cond)) { \
347 RLOGD(format, ##arg); \
350 #define RLOGI_IF(cond, format, arg...) \
352 if (CONDITION(cond)) { \
353 RLOGI(format, ##arg); \
356 #define RLOGW_IF(cond, format, arg...) \
358 if (CONDITION(cond)) { \
359 RLOGW(format, ##arg); \
362 #define RLOGE_IF(cond, format, arg...) \
364 if (CONDITION(cond)) { \
365 RLOGE(format, ##arg); \
368 #define RLOGF_IF(cond, format, arg...) \
370 if (CONDITION(cond)) { \
371 RLOGF(format, ##arg); \
374 #define LOG_ON() ({ do { } while (0); })
375 #define LOGV(format, arg...) NOP(format, ##arg)
376 #define SLOGV(format, arg...) NOP(format, ##arg)
377 #define RLOGV(format, arg...) NOP(format, ##arg)
378 #define ALOGV(format, arg...) NOP(format, ##arg)
379 #define LOGV_IF(cond, format, arg...) NOP(format, ##arg)
380 #define SLOGV_IF(cond, format, arg...) NOP(format, ##arg)
381 #define RLOGV_IF(cond, format, arg...) NOP(format, ##arg)
382 #define SECLOG(...) ({ do { } while (0); })
384 // Don't use above macro no more!! It will be removed -Verbose, Warning and Fatal priority macro.
385 // ---------------------------------------------------------------------
387 * The stuff in the rest of this file should not be used directly.
390 * @brief send log. must specify log_id ,priority, tag and format string.
394 * @remarks you must not use this API directly. use macros instead.
395 * @param[in] log_id log device id
396 * @param[in] prio priority
398 * @param[in] fmt format string
399 * @return Operation result
400 * @retval 0>= Success
403 // you have to use LOG(), SLOG(), RLOG() family not to use __dlog_print() directly
404 // so below example is just for passing Documentation Verification !!!
405 #define LOG_TAG USR_TAG
407 __dlog_print(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly");
410 int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...);
413 * @brief send log with va_list. must specify log_id ,priority, tag and format string.
417 * @remarks you must not use this API directly. use macros instead.
418 * @param[in] log_id log device id
419 * @param[in] prio priority
421 * @param[in] fmt format string
422 * @param[in] ap va_list
423 * @return Operation result
424 * @retval 0>= Success
427 // you have to use LOG_VA(), SLOG_VA(), RLOG_VA() family not to use __dlog_print() directly
428 // so below example is just for passing Documentation Verification !!!
429 #define LOG_TAG USR_TAG
431 __dlog_vprint(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly", ap);
434 int __dlog_vprint(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap);
437 #endif /* __cplusplus */