1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
|
/*
* DLOG
* Copyright (c) 2005-2008, The Android Open Source Project
* Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file dlog-internal.h
* @version 0.4
* @brief This file is the header file of interface of dlog.
*/
#ifndef _DLOG_INTERNAL_H_
#define _DLOG_INTERNAL_H_
#include <tizen_error.h>
#include <stdarg.h>
#include <string.h>
#include "dlog.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* This is the local tag used for the following simplified
* logging macros. You can change this preprocessor definition
* before using the other macros to change the tag.
*/
#ifndef LOG_TAG
#define LOG_TAG NULL
#endif
#ifndef __MODULE__
#define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#endif
#ifdef TIZEN_ENGINEER_MODE
#ifndef TIZEN_DEBUG_ENABLE
#define TIZEN_DEBUG_ENABLE
#endif
#endif
/**
* @internal
* @brief log id
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum {
LOG_ID_MAIN = 0,
LOG_ID_RADIO,
LOG_ID_SYSTEM,
LOG_ID_APPS,
LOG_ID_MAX
} log_id_t;
static inline int __dlog_no_print(const char *fmt __attribute__((unused)), ...) { return 0; }
#define CONDITION(cond) (__builtin_expect((cond) != 0, 0))
#define NOP(...) ({ do { __dlog_no_print(__VA_ARGS__); } while (0); })
// Macro inner work---------------------------------------------------------------
#undef LOG_
#ifdef TIZEN_DEBUG_ENABLE
#define LOG_(id, prio, tag, fmt, arg...) \
({ do { \
__dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
} while (0); })
#else
#define LOG_(id, prio, tag, fmt, arg...) \
({ do { \
if ((int)prio != DLOG_DEBUG) { \
__dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
} \
} while (0); })
#endif
#undef SECURE_LOG_
#ifdef TIZEN_DEBUG_ENABLE
#define SECURE_LOG_(id, prio, tag, fmt, arg...) \
({ do { \
__dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg); \
} while (0); })
#else
#define SECURE_LOG_(id, prio, tag, fmt, arg...) NOP(fmt, ##arg)
#endif
// ---------------------------------------------------------------------
/**
* @internal
* @brief For Secure Log.
* @remarks Normally we strip Secure log from release builds.
* Please use this macros.
*/
/**
* @internal
* @brief For Application and etc.
* @details Simplified macro to send a main log message using the current LOG_TAG.
* Example:
* SECURE_LOGD("app debug %d", num);
* SECURE_LOGE("app error %d", num);
*/
#define SECURE_LOGD(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
#define SECURE_LOGI(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
#define SECURE_LOGW(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
#define SECURE_LOGE(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
#define SECURE_LOGF(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @brief For Framework and system etc.
* @details Simplified macro to send a system log message using the current LOG_TAG.
* Example:
* SECURE_SLOGD("system debug %d", num);
* SECURE_SLOGE("system error %d", num);
*/
#define SECURE_SLOGD(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
#define SECURE_SLOGI(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
#define SECURE_SLOGW(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
#define SECURE_SLOGE(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
#define SECURE_SLOGF(format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @brief For Modem and radio etc.
* @details Simplified macro to send a radio log message using the current LOG_TAG.
* Example:
* SECURE_RLOGD("radio debug %d", num);
* SECURE_RLOGE("radio error %d", num);
*/
#define SECURE_RLOGD(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
#define SECURE_RLOGI(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
#define SECURE_RLOGW(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
#define SECURE_RLOGE(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
#define SECURE_RLOGF(format, arg...) SECURE_LOG_(LOG_ID_RADIO, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @brief For Tizen OSP Application macro.
*/
#define SECURE_ALOGD(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
#define SECURE_ALOGI(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
#define SECURE_ALOGW(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
#define SECURE_ALOGE(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
#define SECURE_ALOGF(format, arg...) SECURE_LOG_(LOG_ID_APPS, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @details If you want use redefined macro.
* You can use this macro.
* This macro need priority and tag arguments.
*/
#define SECURE_LOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
#define SECURE_SLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
#define SECURE_RLOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
#define SECURE_ALOG(priority, tag, format, arg...) SECURE_LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
/**
* @internal
* @brief For Application and etc.
* @details Simplified macro to send a main log message using the current LOG_TAG.
* Example:
* LOGD("app debug %d", num);
* LOGE("app error %d", num);
*/
#ifdef TIZEN_DEBUG_ENABLE
#define LOGD(format, arg...) LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
#else
#define LOGD(format, arg...) NOP(format, ##arg)
#endif
#define LOGI(format, arg...) LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
#define LOGW(format, arg...) LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
#define LOGE(format, arg...) LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
#define LOGF(format, arg...) LOG_(LOG_ID_MAIN, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @brief For Framework and system etc.
* @details Simplified macro to send a system log message using the current LOG_TAG.
* Example:
* SLOGD("system debug %d", num);
* SLOGE("system error %d", num);
*/
#ifdef TIZEN_DEBUG_ENABLE
#define SLOGD(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_DEBUG, LOG_TAG, format, ##arg)
#else
#define SLOGD(format, arg...) NOP(format, ##arg)
#endif
#define SLOGI(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_INFO, LOG_TAG, format, ##arg)
#define SLOGW(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_WARN, LOG_TAG, format, ##arg)
#define SLOGE(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_ERROR, LOG_TAG, format, ##arg)
#define SLOGF(format, arg...) LOG_(LOG_ID_SYSTEM, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @brief For Modem and radio etc.
* @details Simplified macro to send a radio log message using the current LOG_TAG.
* Example:
* RLOGD("radio debug %d", num);
* RLOGE("radio error %d", num);
*/
#ifdef TIZEN_DEBUG_ENABLE
#define RLOGD(format, arg...) LOG_(LOG_ID_RADIO, DLOG_DEBUG, LOG_TAG, format, ##arg)
#else
#define RLOGD(format, arg...) NOP(format, ##arg)
#endif
#define RLOGI(format, arg...) LOG_(LOG_ID_RADIO, DLOG_INFO, LOG_TAG, format, ##arg)
#define RLOGW(format, arg...) LOG_(LOG_ID_RADIO, DLOG_WARN, LOG_TAG, format, ##arg)
#define RLOGE(format, arg...) LOG_(LOG_ID_RADIO, DLOG_ERROR, LOG_TAG, format, ##arg)
#define RLOGF(format, arg...) LOG_(LOG_ID_RADIO, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @brief For Tizen OSP Application macro.
*/
#ifdef TIZEN_DEBUG_ENABLE
#define ALOGD(format, arg...) LOG_(LOG_ID_APPS, DLOG_DEBUG, LOG_TAG, format, ##arg)
#else
#define ALOGD(format, arg...) NOP(format, ##arg)
#endif
#define ALOGI(format, arg...) LOG_(LOG_ID_APPS, DLOG_INFO, LOG_TAG, format, ##arg)
#define ALOGW(format, arg...) LOG_(LOG_ID_APPS, DLOG_WARN, LOG_TAG, format, ##arg)
#define ALOGE(format, arg...) LOG_(LOG_ID_APPS, DLOG_ERROR, LOG_TAG, format, ##arg)
#define ALOGF(format, arg...) LOG_(LOG_ID_APPS, DLOG_FATAL, LOG_TAG, format, ##arg)
/**
* @internal
* @brief Basic log message macro
* @details This macro allows you to specify a priority and a tag
* if you want to use this macro directly, you must add this messages for unity of messages.
* (LOG(prio, tag, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg))
*
* Example:
* #define MYMACRO(prio, tag, format, arg...) \
* LOG(prio, tag, format, ##arg)
*
* MYMACRO(LOG_DEBUG, MYTAG, "test mymacro %d", num);
*
*/
#ifndef LOG
#define LOG(priority, tag, format, arg...) LOG_(LOG_ID_MAIN, D##priority, tag, format, ##arg)
#endif
#define SLOG(priority, tag, format, arg...) LOG_(LOG_ID_SYSTEM, D##priority, tag, format, ##arg)
#define RLOG(priority, tag, format, arg...) LOG_(LOG_ID_RADIO, D##priority, tag, format, ##arg)
#define ALOG(priority, tag, format, arg...) LOG_(LOG_ID_APPS, D##priority, tag, format, ##arg)
/**
* @internal
*/
#define LOG_VA(priority, tag, fmt, args) \
vprint_log(D##priority, tag, fmt, args)
#define ALOG_VA(priority, tag, fmt, args) \
vprint_apps_log(D##priority, tag, fmt, args)
#define RLOG_VA(priority, tag, fmt, args) \
vprint_radio_log(D##priority, tag, fmt, args)
#define SLOG_VA(priority, tag, fmt, args) \
vprint_system_log(D##priority, tag, fmt, args)
#define print_apps_log(prio, tag, fmt...) \
__dlog_print(LOG_ID_APPS, prio, tag, fmt)
#define vprint_apps_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_APPS, prio, tag, fmt)
#define print_log(prio, tag, fmt...) \
__dlog_print(LOG_ID_MAIN, prio, tag, fmt)
#define vprint_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_MAIN, prio, tag, fmt)
#define print_radio_log(prio, tag, fmt...)\
__dlog_print(LOG_ID_RADIO, prio, tag, fmt)
#define vprint_radio_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_RADIO, prio, tag, fmt)
#define print_system_log(prio, tag, fmt...)\
__dlog_print(LOG_ID_SYSTEM, prio, tag, fmt)
#define vprint_system_log(prio, tag, fmt...) \
__dlog_vprint(LOG_ID_SYSTEM, prio, tag, fmt)
// ---------------------------------------------------------------------
// Don't use below macro no more!! It will be removed -- Verbose and Fatal priority macro will be removed --
#define COMPATIBILITY_ON
#ifdef COMPATIBILITY_ON
/**
* @internal
* @breif Conditional Macro.
* @remarks Don't use this macro. It's just compatibility.
* It will be deprecated.
*/
#define LOGD_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
LOGD(format, ##arg); \
} \
} while (0); })
#define LOGI_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
LOGI(format, ##arg); \
} \
} while (0); })
#define LOGW_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
LOGW(format, ##arg); \
} \
} while (0); })
#define LOGE_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
LOGE(format, ##arg); \
} \
} while (0); })
#define LOGF_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
LOGF(format, ##arg); \
} \
} while (0); })
#define SLOGD_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
SLOGD(format, ##arg); \
} \
} while (0); })
#define SLOGI_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
SLOGI(format, ##arg); \
} \
} while (0); })
#define SLOGW_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
SLOGW(format, ##arg); \
} \
} while (0); })
#define SLOGE_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
SLOGE(format, ##arg); \
} \
} while (0); })
#define SLOGF_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
SLOGF(format, ##arg); \
} \
} while (0); })
#define RLOGD_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
RLOGD(format, ##arg); \
} \
} while (0); })
#define RLOGI_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
RLOGI(format, ##arg); \
} \
} while (0); })
#define RLOGW_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
RLOGW(format, ##arg); \
} \
} while (0); })
#define RLOGE_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
RLOGE(format, ##arg); \
} \
} while (0); })
#define RLOGF_IF(cond, format, arg...) \
({ do { \
if (CONDITION(cond)) { \
RLOGF(format, ##arg); \
} \
} while (0); })
#define LOG_ON() ({ do { } while (0); })
#define LOGV(format, arg...) NOP(format, ##arg)
#define SLOGV(format, arg...) NOP(format, ##arg)
#define RLOGV(format, arg...) NOP(format, ##arg)
#define ALOGV(format, arg...) NOP(format, ##arg)
#define LOGV_IF(cond, format, arg...) NOP(format, ##arg)
#define SLOGV_IF(cond, format, arg...) NOP(format, ##arg)
#define RLOGV_IF(cond, format, arg...) NOP(format, ##arg)
#define SECLOG(...) ({ do { } while (0); })
#endif
// ---------------------------------------------------------------------
/*
* The stuff in the rest of this file should not be used directly.
*/
/**
* @internal
* @brief Send log.
* @details Use LOG(), SLOG(), RLOG() family
* not to use __dlog_print() directly
* @remarks Must not use this API directly. use macros instead.
* @param[in] log_id log device id
* @param[in] prio priority
* @param[in] tag tag
* @param[in] fmt format string
* @return Operation result
* @retval 0>= Success
* @retval -1 Error
* @pre none
* @post none
* @see __dlog_print
* @code
#define LOG_TAG USR_TAG
#include<dlog-internal.h>
__dlog_print(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly");
* @endcode
*/
int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...);
/**
* @internal
* @brief Send log with va_list.
* @details Use LOG_VA(), SLOG_VA(), RLOG_VA() family
not to use __dlog_vprint() directly
* @remarks Must not use this API directly. use macros instead.
* @param[in] log_id log device id
* @param[in] prio priority
* @param[in] tag tag
* @param[in] fmt format string
* @param[in] ap va_list
* @return Operation result
* @retval 0>= Success
* @retval -1 Error
* @pre none
* @post none
* @see __dlog_vprint
* @code
#define LOG_TAG USR_TAG
#include<dlog-internal.h>
__dlog_vprint(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly", ap);
* @endcode
*/
int __dlog_vprint(log_id_t log_id, int prio, const char *tag, const char *fmt, va_list ap);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _DLOG_INTERNAL_H_*/
|