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.
21 * @brief This file is the header file of interface of dlog.
24 * @addtogroup APPLICATION_FRAMEWORK
40 #endif /* __cplusplus */
43 * Normally we strip LOGV (VERBOSE messages) from release builds.
54 * This is the local tag used for the following simplified
55 * logging macros. You can change this preprocessor definition
56 * before using the other macros to change the tag.
63 #define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
67 * log priority values, in ascending priority order.
79 DLOG_PRIO_MAX /* Keep this always at the end. */
90 #define CONDITION(cond) (__builtin_expect((cond) != 0, 0))
92 #define _SECURE_LOG /* Temporary default added, This define code will be removed */
94 // Macro inner work---------------------------------------------------------------
102 #define LOG_(id, prio, tag, fmt, arg...) \
103 ( __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg))
105 #define SECURE_LOG_(id, prio, tag, fmt, arg...) \
106 (_SECURE_ ? ( __dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg)) : (0))
107 // ---------------------------------------------------------------------
110 * Normally we strip Secure log from release builds.
111 * Please use this macros.
114 * For Application and etc.
115 * Simplified macro to send a main log message using the current LOG_TAG.
117 * SECURE_LOGD("app debug %d", num);
118 * SECURE_LOGE("app error %d", num);
120 #define SECURE_LOGD(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
121 #define SECURE_LOGI(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
122 #define SECURE_LOGW(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
123 #define SECURE_LOGE(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
125 * For Framework and system etc.
126 * Simplified macro to send a system log message using the current LOG_TAG.
128 * SECURE_SLOGD("system debug %d", num);
129 * SECURE_SLOGE("system error %d", num);
131 #define SECURE_SLOGD(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
132 #define SECURE_SLOGI(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
133 #define SECURE_SLOGW(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
134 #define SECURE_SLOGE(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
136 * For Modem and radio etc.
137 * Simplified macro to send a radio log message using the current LOG_TAG.
139 * SECURE_RLOGD("radio debug %d", num);
140 * SECURE_RLOGE("radio error %d", num);
142 #define SECURE_RLOGD(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
143 #define SECURE_RLOGI(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
144 #define SECURE_RLOGW(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
145 #define SECURE_RLOGE(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
147 * For Tizen OSP Application macro.
149 #define SECURE_ALOGD(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
150 #define SECURE_ALOGI(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
151 #define SECURE_ALOGW(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
152 #define SECURE_ALOGE(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
154 * If you want use redefined macro.
155 * You can use this macro.
156 * This macro need priority and tag arguments.
158 #define SECURE_LOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
159 #define SECURE_SLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
160 #define SECURE_RLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
161 #define SECURE_ALOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
163 #define SECLOG(format, arg...) do { } while (0)
165 * For Application and etc.
166 * Simplified macro to send a main log message using the current LOG_TAG.
168 * LOGD("app debug %d", num);
169 * LOGE("app error %d", num);
171 #define LOGD(format, arg...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
172 #define LOGI(format, arg...) LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
173 #define LOGW(format, arg...) LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
174 #define LOGE(format, arg...) LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
176 * For Framework and system etc.
177 * Simplified macro to send a system log message using the current LOG_TAG.
179 * SLOGD("system debug %d", num);
180 * SLOGE("system error %d", num);
182 #define SLOGD(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
183 #define SLOGI(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
184 #define SLOGW(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
185 #define SLOGE(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
187 * For Modem and radio etc.
188 * Simplified macro to send a radio log message using the current LOG_TAG.
190 * RLOGD("radio debug %d", num);
191 * RLOGE("radio error %d", num);
193 #define RLOGD(format, arg...) LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
194 #define RLOGI(format, arg...) LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
195 #define RLOGW(format, arg...) LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
196 #define RLOGE(format, arg...) LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
198 * For Tizen OSP Application macro.
200 #define ALOGD(format, arg...) LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
201 #define ALOGI(format, arg...) LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
202 #define ALOGW(format, arg...) LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
203 #define ALOGE(format, arg...) LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
207 * Don't use this macro. It's just compatibility.
209 #define LOGD_IF(cond, format, arg...) \
210 ((CONDITION(cond)) ? (LOGD(format, ##arg)) : (0))
211 #define LOGI_IF(cond, format, arg...) \
212 ((CONDITION(cond)) ? (LOGI(format, ##arg)) : (0))
213 #define LOGW_IF(cond, format, arg...) \
214 ((CONDITION(cond)) ? (LOGW(format, ##arg)) : (0))
215 #define LOGE_IF(cond, format, arg...) \
216 ((CONDITION(cond)) ? (LOGE(format, ##arg)) : (0))
217 #define SLOGD_IF(cond, format, arg...) \
218 ((CONDITION(cond)) ? (SLOGD(format, ##arg)) : (0))
219 #define SLOGI_IF(cond, format, arg...) \
220 ((CONDITION(cond)) ? (SLOGI(format, ##arg)) : (0))
221 #define SLOGW_IF(cond, format, arg...) \
222 ((CONDITION(cond)) ? (SLOGW(format, ##arg)) : (0))
223 #define SLOGE_IF(cond, format, arg...) \
224 ((CONDITION(cond)) ? (SLOGE(format, ##arg)) : (0))
225 #define RLOGD_IF(cond, format, arg...) \
226 ((CONDITION(cond)) ? (RLOGD(format, ##arg)) : (0))
227 #define RLOGI_IF(cond, format, arg...) \
228 ((CONDITION(cond)) ? (RLOGI(format, ##arg)) : (0))
229 #define RLOGW_IF(cond, format, arg...) \
230 ((CONDITION(cond)) ? (RLOGW(format, ##arg)) : (0))
231 #define RLOGE_IF(cond, format, arg...) \
232 ((CONDITION(cond)) ? (RLOGE(format, ##arg)) : (0))
235 * Basic log message macro that allows you to specify a priority and a tag
236 * if you want to use this macro directly, you must add this messages for unity of messages.
237 * (LOG(prio, tag, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg))
240 * #define MYMACRO(prio, tag, format, arg...) \
241 * LOG(prio, tag, format, ##arg)
243 * MYMACRO(LOG_DEBUG, MYTAG, "test mymacro %d", num);
247 #define LOG(priority, tag, format, arg...) LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
249 #define SLOG(priority, tag, format, arg...) LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
250 #define RLOG(priority, tag, format, arg...) LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
251 #define ALOG(priority, tag, format, arg...) LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
254 // ---------------------------------------------------------------------
255 // Don't use below macro no more!! It will be removed -- Verbose and Fatal priority macro will be removed --
256 #define COMPATIBILITY_ON
258 #ifdef COMPATIBILITY_ON
259 #define LOG_ON() _get_logging_on()
261 #define LOGV(format, arg...) (0)
263 #define LOGV(format, arg...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
265 #define LOGF(format, arg...) LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
267 #define SLOGV(format, arg...) (0)
269 #define SLOGV(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
271 #define SLOGF(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
273 #define RLOGV(format, arg...) (0)
275 #define RLOGV(format, arg...) LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
277 #define RLOGF(format, arg...) LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
279 #define ALOGV(format, arg...) (0)
281 #define ALOGV(format, arg...) LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
283 #define ALOGF(format, arg...) LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
284 #define LOGV_IF(cond, format, arg...) \
285 ((CONDITION(cond)) ? (LOGD(format, ##arg)) : (0))
286 #define LOGF_IF(cond, format, arg...) \
287 ((CONDITION(cond)) ? (LOGE(format, ##arg)) : (0))
288 #define SLOGV_IF(cond, format, arg...) \
289 ((CONDITION(cond)) ? (SLOGD(format, ##arg)) : (0))
290 #define SLOGF_IF(cond, format, arg...) \
291 ((CONDITION(cond)) ? (SLOGE(format, ##arg)) : (0))
292 #define RLOGV_IF(cond, format, arg...) \
293 ((CONDITION(cond)) ? (RLOGD(format, ##arg)) : (0))
294 #define RLOGF_IF(cond, format, arg...) \
295 ((CONDITION(cond)) ? (RLOGE(format, ##arg)) : (0))
296 #define LOG_VA(priority, tag, fmt, args) \
297 vprint_log(D##priority, tag, fmt, args)
298 #define ALOG_VA(priority, tag, fmt, args) \
299 vprint_apps_log(D##priority, tag, fmt, args)
300 #define RLOG_VA(priority, tag, fmt, args) \
301 vprint_radio_log(D##priority, tag, fmt, args)
302 #define SLOG_VA(priority, tag, fmt, args) \
303 vprint_system_log(D##priority, tag, fmt, args)
304 #define print_apps_log(prio, tag, fmt...) \
305 __dlog_print(LOG_ID_APPS, prio, tag, fmt)
306 #define vprint_apps_log(prio, tag, fmt...) \
307 __dlog_vprint(LOG_ID_APPS, prio, tag, fmt)
308 #define print_log(prio, tag, fmt...) \
309 __dlog_print(LOG_ID_MAIN, prio, tag, fmt)
310 #define vprint_log(prio, tag, fmt...) \
311 __dlog_vprint(LOG_ID_MAIN, prio, tag, fmt)
312 #define print_radio_log(prio, tag, fmt...)\
313 __dlog_print(LOG_ID_RADIO, prio, tag, fmt)
314 #define vprint_radio_log(prio, tag, fmt...) \
315 __dlog_vprint(LOG_ID_RADIO, prio, tag, fmt)
316 #define print_system_log(prio, tag, fmt...)\
317 __dlog_print(LOG_ID_SYSTEM, prio, tag, fmt)
318 #define vprint_system_log(prio, tag, fmt...) \
319 __dlog_vprint(LOG_ID_SYSTEM, prio, tag, fmt)
321 // Don't use above macro no more!! It will be removed -Verbose, Warning and Fatal priority macro.
322 // ---------------------------------------------------------------------
324 * The stuff in the rest of this file should not be used directly.
327 * @brief send log. must specify log_id ,priority, tag and format string.
331 * @remarks you must not use this API directly. use macros instead.
332 * @param[in] log_id log device id
333 * @param[in] prio priority
335 * @param[in] fmt format string
336 * @return Operation result
337 * @retval 0>= Success
340 // you have to use LOG(), SLOG(), RLOG() family not to use __dlog_print() directly
341 // so below example is just for passing Documentation Verification !!!
342 #define LOG_TAG USR_TAG
344 __dlog_print(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly");
347 int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...);
350 * @brief send log with va_list. must specify log_id ,priority, tag and format string.
354 * @remarks you must not use this API directly. use macros instead.
355 * @param[in] log_id log device id
356 * @param[in] prio priority
358 * @param[in] fmt format string
359 * @param[in] ap va_list
360 * @return Operation result
361 * @retval 0>= Success
364 // you have to use LOG_VA(), SLOG_VA(), RLOG_VA() family not to use __dlog_print() directly
365 // so below example is just for passing Documentation Verification !!!
366 #define LOG_TAG USR_TAG
368 __dlog_vprint(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly", ap);
371 int __dlog_vprint(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap);
372 int _get_logging_on(void);
375 #endif /* __cplusplus */