blob: fe711efa430ee2e26132ebf59b7ea86edc962f83 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/*
2 * Copyright (C) 2005 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//
18// C/C++ logging functions. See the logging documentation for API details.
19//
20// We'd like these to be available from C code (in case we import some from
21// somewhere), so this has a C interface.
22//
23// The output will be correct when the log file is shared between multiple
24// threads and/or multiple processes so long as the operating system
25// supports O_APPEND. These calls have mutex-protected data structures
26// and so are NOT reentrant. Do not use LOG in a signal handler.
27//
28#ifndef _LIBS_CUTILS_LOG_H
29#define _LIBS_CUTILS_LOG_H
30
31#include <stdio.h>
32#include <time.h>
33#include <sys/types.h>
34#include <unistd.h>
35#ifdef HAVE_PTHREADS
36#include <pthread.h>
37#endif
38#include <stdarg.h>
39
40#include <cutils/uio.h>
41#include <cutils/logd.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47// ---------------------------------------------------------------------
48
49/*
Steve Block66b68752011-10-20 11:54:09 +010050 * Normally we strip ALOGV (VERBOSE messages) from release builds.
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080051 * You can modify this (for example with "#define LOG_NDEBUG 0"
52 * at the top of your source file) to change that behavior.
53 */
54#ifndef LOG_NDEBUG
55#ifdef NDEBUG
56#define LOG_NDEBUG 1
57#else
58#define LOG_NDEBUG 0
59#endif
60#endif
61
62/*
63 * This is the local tag used for the following simplified
64 * logging macros. You can change this preprocessor definition
65 * before using the other macros to change the tag.
66 */
67#ifndef LOG_TAG
68#define LOG_TAG NULL
69#endif
70
71// ---------------------------------------------------------------------
72
73/*
74 * Simplified macro to send a verbose log message using the current LOG_TAG.
75 */
Steve Block66b68752011-10-20 11:54:09 +010076#ifndef ALOGV
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080077#if LOG_NDEBUG
Steve Block66b68752011-10-20 11:54:09 +010078#define ALOGV(...) ((void)0)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080079#else
Steve Block66b68752011-10-20 11:54:09 +010080#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080081#endif
Steve Block66b68752011-10-20 11:54:09 +010082// Temporary measure for code still using old LOG macros.
83#ifndef LOGV
84#define LOGV ALOGV
85#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080086#endif
87
88#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
89
Steve Block66b68752011-10-20 11:54:09 +010090#ifndef ALOGV_IF
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080091#if LOG_NDEBUG
Steve Block66b68752011-10-20 11:54:09 +010092#define ALOGV_IF(cond, ...) ((void)0)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080093#else
Steve Block66b68752011-10-20 11:54:09 +010094#define ALOGV_IF(cond, ...) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080095 ( (CONDITION(cond)) \
Steve Block61fbcbe2011-10-12 17:22:43 +010096 ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080097 : (void)0 )
98#endif
Steve Block66b68752011-10-20 11:54:09 +010099// Temporary measure for code still using old LOG macros.
100#ifndef LOGV_IF
101#define LOGV_IF ALOGV_IF
102#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800103#endif
104
105/*
106 * Simplified macro to send a debug log message using the current LOG_TAG.
107 */
108#ifndef LOGD
Steve Block61fbcbe2011-10-12 17:22:43 +0100109#define LOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
Steve Blocke7e7fac2011-12-22 15:00:35 +0000110#define ALOGD LOGD
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800111#endif
112
113#ifndef LOGD_IF
114#define LOGD_IF(cond, ...) \
115 ( (CONDITION(cond)) \
Steve Block61fbcbe2011-10-12 17:22:43 +0100116 ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800117 : (void)0 )
Steve Blocke7e7fac2011-12-22 15:00:35 +0000118#define ALOGD_IF LOGD_IF
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800119#endif
120
121/*
122 * Simplified macro to send an info log message using the current LOG_TAG.
123 */
124#ifndef LOGI
Steve Block61fbcbe2011-10-12 17:22:43 +0100125#define LOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
Steve Blocke7e7fac2011-12-22 15:00:35 +0000126#define ALOGI LOGI
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800127#endif
128
129#ifndef LOGI_IF
130#define LOGI_IF(cond, ...) \
131 ( (CONDITION(cond)) \
Steve Block61fbcbe2011-10-12 17:22:43 +0100132 ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800133 : (void)0 )
Steve Blocke7e7fac2011-12-22 15:00:35 +0000134#define ALOGI_IF LOGI_IF
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800135#endif
136
137/*
138 * Simplified macro to send a warning log message using the current LOG_TAG.
139 */
140#ifndef LOGW
Steve Block61fbcbe2011-10-12 17:22:43 +0100141#define LOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
Steve Blocke7e7fac2011-12-22 15:00:35 +0000142#define ALOGW LOGW
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800143#endif
144
145#ifndef LOGW_IF
146#define LOGW_IF(cond, ...) \
147 ( (CONDITION(cond)) \
Steve Block61fbcbe2011-10-12 17:22:43 +0100148 ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800149 : (void)0 )
Steve Blocke7e7fac2011-12-22 15:00:35 +0000150#define ALOGW_IF LOGW_IF
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800151#endif
152
153/*
154 * Simplified macro to send an error log message using the current LOG_TAG.
155 */
156#ifndef LOGE
Steve Block61fbcbe2011-10-12 17:22:43 +0100157#define LOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
Steve Blocke7e7fac2011-12-22 15:00:35 +0000158#define ALOGE LOGE
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800159#endif
160
161#ifndef LOGE_IF
162#define LOGE_IF(cond, ...) \
163 ( (CONDITION(cond)) \
Steve Block61fbcbe2011-10-12 17:22:43 +0100164 ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800165 : (void)0 )
Steve Blocke7e7fac2011-12-22 15:00:35 +0000166#define ALOGE_IF LOGE_IF
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800167#endif
168
169// ---------------------------------------------------------------------
170
171/*
172 * Conditional based on whether the current LOG_TAG is enabled at
173 * verbose priority.
174 */
Steve Block66b68752011-10-20 11:54:09 +0100175#ifndef IF_ALOGV
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800176#if LOG_NDEBUG
Steve Block66b68752011-10-20 11:54:09 +0100177#define IF_ALOGV() if (false)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800178#else
Steve Block66b68752011-10-20 11:54:09 +0100179#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800180#endif
Steve Block66b68752011-10-20 11:54:09 +0100181// Temporary measure for code still using old LOG macros.
182#ifndef IF_LOGV
183#define IF_LOGV IF_ALOGV
184#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800185#endif
186
187/*
188 * Conditional based on whether the current LOG_TAG is enabled at
189 * debug priority.
190 */
191#ifndef IF_LOGD
Steve Block61fbcbe2011-10-12 17:22:43 +0100192#define IF_LOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
Steve Blocke7e7fac2011-12-22 15:00:35 +0000193#define IF_ALOGD IF_LOGD
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800194#endif
195
196/*
197 * Conditional based on whether the current LOG_TAG is enabled at
198 * info priority.
199 */
200#ifndef IF_LOGI
Steve Block61fbcbe2011-10-12 17:22:43 +0100201#define IF_LOGI() IF_ALOG(LOG_INFO, LOG_TAG)
Steve Blocke7e7fac2011-12-22 15:00:35 +0000202#define IF_ALOGI IF_LOGI
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800203#endif
204
205/*
206 * Conditional based on whether the current LOG_TAG is enabled at
207 * warn priority.
208 */
209#ifndef IF_LOGW
Steve Block61fbcbe2011-10-12 17:22:43 +0100210#define IF_LOGW() IF_ALOG(LOG_WARN, LOG_TAG)
Steve Blocke7e7fac2011-12-22 15:00:35 +0000211#define IF_ALOGW IF_LOGW
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800212#endif
213
214/*
215 * Conditional based on whether the current LOG_TAG is enabled at
216 * error priority.
217 */
218#ifndef IF_LOGE
Steve Block61fbcbe2011-10-12 17:22:43 +0100219#define IF_LOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
Steve Blocke7e7fac2011-12-22 15:00:35 +0000220#define IF_ALOGE IF_LOGE
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800221#endif
222
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800223
224// ---------------------------------------------------------------------
225
226/*
227 * Simplified macro to send a verbose system log message using the current LOG_TAG.
228 */
229#ifndef SLOGV
230#if LOG_NDEBUG
231#define SLOGV(...) ((void)0)
232#else
233#define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
234#endif
235#endif
236
237#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
238
239#ifndef SLOGV_IF
240#if LOG_NDEBUG
241#define SLOGV_IF(cond, ...) ((void)0)
242#else
243#define SLOGV_IF(cond, ...) \
244 ( (CONDITION(cond)) \
245 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
246 : (void)0 )
247#endif
248#endif
249
250/*
251 * Simplified macro to send a debug system log message using the current LOG_TAG.
252 */
253#ifndef SLOGD
254#define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
255#endif
256
257#ifndef SLOGD_IF
258#define SLOGD_IF(cond, ...) \
259 ( (CONDITION(cond)) \
260 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
261 : (void)0 )
262#endif
263
264/*
265 * Simplified macro to send an info system log message using the current LOG_TAG.
266 */
267#ifndef SLOGI
268#define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
269#endif
270
271#ifndef SLOGI_IF
272#define SLOGI_IF(cond, ...) \
273 ( (CONDITION(cond)) \
274 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
275 : (void)0 )
276#endif
277
278/*
279 * Simplified macro to send a warning system log message using the current LOG_TAG.
280 */
281#ifndef SLOGW
282#define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
283#endif
284
285#ifndef SLOGW_IF
286#define SLOGW_IF(cond, ...) \
287 ( (CONDITION(cond)) \
288 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
289 : (void)0 )
290#endif
291
292/*
293 * Simplified macro to send an error system log message using the current LOG_TAG.
294 */
295#ifndef SLOGE
296#define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
297#endif
298
299#ifndef SLOGE_IF
300#define SLOGE_IF(cond, ...) \
301 ( (CONDITION(cond)) \
302 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
303 : (void)0 )
304#endif
305
306
307
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800308// ---------------------------------------------------------------------
309
310/*
311 * Log a fatal error. If the given condition fails, this stops program
312 * execution like a normal assertion, but also generating the given message.
313 * It is NOT stripped from release builds. Note that the condition test
314 * is -inverted- from the normal assert() semantics.
315 */
Alexandre Elias412514e2011-03-29 16:24:45 -0700316#ifndef LOG_ALWAYS_FATAL_IF
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800317#define LOG_ALWAYS_FATAL_IF(cond, ...) \
318 ( (CONDITION(cond)) \
Chris Pearson19299902010-06-02 16:25:35 -0700319 ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800320 : (void)0 )
Alexandre Elias412514e2011-03-29 16:24:45 -0700321#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800322
Alexandre Elias412514e2011-03-29 16:24:45 -0700323#ifndef LOG_ALWAYS_FATAL
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800324#define LOG_ALWAYS_FATAL(...) \
Chris Pearson19299902010-06-02 16:25:35 -0700325 ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) )
Alexandre Elias412514e2011-03-29 16:24:45 -0700326#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800327
328/*
329 * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
330 * are stripped out of release builds.
331 */
332#if LOG_NDEBUG
333
Alexandre Elias412514e2011-03-29 16:24:45 -0700334#ifndef LOG_FATAL_IF
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800335#define LOG_FATAL_IF(cond, ...) ((void)0)
Alexandre Elias412514e2011-03-29 16:24:45 -0700336#endif
337#ifndef LOG_FATAL
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800338#define LOG_FATAL(...) ((void)0)
Alexandre Elias412514e2011-03-29 16:24:45 -0700339#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800340
341#else
342
Alexandre Elias412514e2011-03-29 16:24:45 -0700343#ifndef LOG_FATAL_IF
Chris Pearson19299902010-06-02 16:25:35 -0700344#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__)
Alexandre Elias412514e2011-03-29 16:24:45 -0700345#endif
346#ifndef LOG_FATAL
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800347#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
Alexandre Elias412514e2011-03-29 16:24:45 -0700348#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800349
350#endif
351
352/*
353 * Assertion that generates a log message when the assertion fails.
354 * Stripped out of release builds. Uses the current LOG_TAG.
355 */
Alexandre Elias412514e2011-03-29 16:24:45 -0700356#ifndef LOG_ASSERT
Chris Pearson19299902010-06-02 16:25:35 -0700357#define LOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800358//#define LOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond)
Steve Blocka9b84a72012-01-09 22:50:36 +0000359#define ALOG_ASSERT LOG_ASSERT
Alexandre Elias412514e2011-03-29 16:24:45 -0700360#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800361
362// ---------------------------------------------------------------------
363
364/*
365 * Basic log message macro.
366 *
367 * Example:
Steve Block61fbcbe2011-10-12 17:22:43 +0100368 * ALOG(LOG_WARN, NULL, "Failed with error %d", errno);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800369 *
370 * The second argument may be NULL or "" to indicate the "global" tag.
371 */
Steve Block61fbcbe2011-10-12 17:22:43 +0100372#ifndef ALOG
373#define ALOG(priority, tag, ...) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800374 LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
Steve Block61fbcbe2011-10-12 17:22:43 +0100375// Temporary measure for code still using old LOG macros.
376#ifndef LOG
377#define LOG ALOG
378#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800379#endif
380
381/*
382 * Log macro that allows you to specify a number for the priority.
383 */
384#ifndef LOG_PRI
385#define LOG_PRI(priority, tag, ...) \
386 android_printLog(priority, tag, __VA_ARGS__)
387#endif
388
389/*
390 * Log macro that allows you to pass in a varargs ("args" is a va_list).
391 */
392#ifndef LOG_PRI_VA
393#define LOG_PRI_VA(priority, tag, fmt, args) \
394 android_vprintLog(priority, NULL, tag, fmt, args)
395#endif
396
397/*
398 * Conditional given a desired logging priority and tag.
399 */
Steve Block61fbcbe2011-10-12 17:22:43 +0100400#ifndef IF_ALOG
401#define IF_ALOG(priority, tag) \
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800402 if (android_testLog(ANDROID_##priority, tag))
Steve Block61fbcbe2011-10-12 17:22:43 +0100403// Temporary measure for code still using old LOG macros.
404#ifndef IF_LOG
405#define IF_LOG IF_ALOG
406#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800407#endif
408
409// ---------------------------------------------------------------------
410
411/*
412 * Event logging.
413 */
414
415/*
416 * Event log entry types. These must match up with the declarations in
417 * java/android/android/util/EventLog.java.
418 */
419typedef enum {
420 EVENT_TYPE_INT = 0,
421 EVENT_TYPE_LONG = 1,
422 EVENT_TYPE_STRING = 2,
423 EVENT_TYPE_LIST = 3,
424} AndroidEventLogType;
425
426
Alexandre Elias412514e2011-03-29 16:24:45 -0700427#ifndef LOG_EVENT_INT
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800428#define LOG_EVENT_INT(_tag, _value) { \
429 int intBuf = _value; \
430 (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \
431 sizeof(intBuf)); \
432 }
Alexandre Elias412514e2011-03-29 16:24:45 -0700433#endif
434#ifndef LOG_EVENT_LONG
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800435#define LOG_EVENT_LONG(_tag, _value) { \
436 long long longBuf = _value; \
437 (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \
438 sizeof(longBuf)); \
439 }
Alexandre Elias412514e2011-03-29 16:24:45 -0700440#endif
441#ifndef LOG_EVENT_STRING
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800442#define LOG_EVENT_STRING(_tag, _value) \
443 ((void) 0) /* not implemented -- must combine len with string */
Alexandre Elias412514e2011-03-29 16:24:45 -0700444#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800445/* TODO: something for LIST */
446
447/*
448 * ===========================================================================
449 *
450 * The stuff in the rest of this file should not be used directly.
451 */
452
453#define android_printLog(prio, tag, fmt...) \
454 __android_log_print(prio, tag, fmt)
455
456#define android_vprintLog(prio, cond, tag, fmt...) \
457 __android_log_vprint(prio, tag, fmt)
458
Chris Pearson19299902010-06-02 16:25:35 -0700459/* XXX Macros to work around syntax errors in places where format string
460 * arg is not passed to LOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
461 * (happens only in debug builds).
462 */
463
464/* Returns 2nd arg. Used to substitute default value if caller's vararg list
465 * is empty.
466 */
467#define __android_second(dummy, second, ...) second
468
469/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
470 * returns nothing.
471 */
472#define __android_rest(first, ...) , ## __VA_ARGS__
473
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800474#define android_printAssert(cond, tag, fmt...) \
Chris Pearson19299902010-06-02 16:25:35 -0700475 __android_log_assert(cond, tag, \
476 __android_second(0, ## fmt, NULL) __android_rest(fmt))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800477
478#define android_writeLog(prio, tag, text) \
479 __android_log_write(prio, tag, text)
480
481#define android_bWriteLog(tag, payload, len) \
482 __android_log_bwrite(tag, payload, len)
483#define android_btWriteLog(tag, type, payload, len) \
484 __android_log_btwrite(tag, type, payload, len)
Chris Pearson19299902010-06-02 16:25:35 -0700485
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800486// TODO: remove these prototypes and their users
487#define android_testLog(prio, tag) (1)
488#define android_writevLog(vec,num) do{}while(0)
489#define android_write1Log(str,len) do{}while (0)
490#define android_setMinPriority(tag, prio) do{}while(0)
491//#define android_logToCallback(func) do{}while(0)
492#define android_logToFile(tag, file) (0)
493#define android_logToFd(tag, fd) (0)
494
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800495typedef enum {
496 LOG_ID_MAIN = 0,
497 LOG_ID_RADIO = 1,
498 LOG_ID_EVENTS = 2,
499 LOG_ID_SYSTEM = 3,
500
501 LOG_ID_MAX
502} log_id_t;
503
504/*
505 * Send a simple string to the log.
506 */
507int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
508int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...);
509
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800510
511#ifdef __cplusplus
512}
513#endif
514
515#endif // _LIBS_CUTILS_LOG_H