widget/gonk/libui/cutils_log.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 * Copyright (C) 2005 The Android Open Source Project
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16
michael@0 17 //
michael@0 18 // C/C++ logging functions. See the logging documentation for API details.
michael@0 19 //
michael@0 20 // We'd like these to be available from C code (in case we import some from
michael@0 21 // somewhere), so this has a C interface.
michael@0 22 //
michael@0 23 // The output will be correct when the log file is shared between multiple
michael@0 24 // threads and/or multiple processes so long as the operating system
michael@0 25 // supports O_APPEND. These calls have mutex-protected data structures
michael@0 26 // and so are NOT reentrant. Do not use LOG in a signal handler.
michael@0 27 //
michael@0 28 #if !defined(_LIBS_CUTILS_LOG_H) && !defined(_LIBS_LOG_LOG_H)
michael@0 29 #define _LIBS_LOG_LOG_H
michael@0 30 #define _LIBS_CUTILS_LOG_H
michael@0 31
michael@0 32 #include <stdio.h>
michael@0 33 #include <time.h>
michael@0 34 #include <sys/types.h>
michael@0 35 #include <unistd.h>
michael@0 36 #ifdef HAVE_PTHREADS
michael@0 37 #include <pthread.h>
michael@0 38 #endif
michael@0 39 #include <stdarg.h>
michael@0 40
michael@0 41 #if ANDROID_VERSION >= 19
michael@0 42 #include <log/uio.h>
michael@0 43 #include <log/logd.h>
michael@0 44 #else
michael@0 45 #include <cutils/uio.h>
michael@0 46 #include <cutils/logd.h>
michael@0 47 #endif
michael@0 48
michael@0 49 #ifdef __cplusplus
michael@0 50 extern "C" {
michael@0 51 #endif
michael@0 52
michael@0 53 // ---------------------------------------------------------------------
michael@0 54
michael@0 55 /*
michael@0 56 * Normally we strip ALOGV (VERBOSE messages) from release builds.
michael@0 57 * You can modify this (for example with "#define LOG_NDEBUG 0"
michael@0 58 * at the top of your source file) to change that behavior.
michael@0 59 */
michael@0 60 #ifndef LOG_NDEBUG
michael@0 61 #ifdef NDEBUG
michael@0 62 #define LOG_NDEBUG 1
michael@0 63 #else
michael@0 64 #define LOG_NDEBUG 0
michael@0 65 #endif
michael@0 66 #endif
michael@0 67
michael@0 68 /*
michael@0 69 * This is the local tag used for the following simplified
michael@0 70 * logging macros. You can change this preprocessor definition
michael@0 71 * before using the other macros to change the tag.
michael@0 72 */
michael@0 73 #ifndef LOG_TAG
michael@0 74 #define LOG_TAG NULL
michael@0 75 #endif
michael@0 76
michael@0 77 // ---------------------------------------------------------------------
michael@0 78
michael@0 79 /*
michael@0 80 * Simplified macro to send a verbose log message using the current LOG_TAG.
michael@0 81 */
michael@0 82 #ifndef ALOGV
michael@0 83 #if LOG_NDEBUG
michael@0 84 #define ALOGV(...) ((void)0)
michael@0 85 #else
michael@0 86 #define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
michael@0 87 #endif
michael@0 88 #endif
michael@0 89
michael@0 90 #define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
michael@0 91
michael@0 92 #ifndef ALOGV_IF
michael@0 93 #if LOG_NDEBUG
michael@0 94 #define ALOGV_IF(cond, ...) ((void)0)
michael@0 95 #else
michael@0 96 #define ALOGV_IF(cond, ...) \
michael@0 97 ( (CONDITION(cond)) \
michael@0 98 ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
michael@0 99 : (void)0 )
michael@0 100 #endif
michael@0 101 #endif
michael@0 102
michael@0 103 /*
michael@0 104 * Simplified macro to send a debug log message using the current LOG_TAG.
michael@0 105 */
michael@0 106 #ifndef ALOGD
michael@0 107 #define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
michael@0 108 #endif
michael@0 109
michael@0 110 #ifndef ALOGD_IF
michael@0 111 #define ALOGD_IF(cond, ...) \
michael@0 112 ( (CONDITION(cond)) \
michael@0 113 ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
michael@0 114 : (void)0 )
michael@0 115 #endif
michael@0 116
michael@0 117 /*
michael@0 118 * Simplified macro to send an info log message using the current LOG_TAG.
michael@0 119 */
michael@0 120 #ifndef ALOGI
michael@0 121 #define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
michael@0 122 #endif
michael@0 123
michael@0 124 #ifndef ALOGI_IF
michael@0 125 #define ALOGI_IF(cond, ...) \
michael@0 126 ( (CONDITION(cond)) \
michael@0 127 ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
michael@0 128 : (void)0 )
michael@0 129 #endif
michael@0 130
michael@0 131 /*
michael@0 132 * Simplified macro to send a warning log message using the current LOG_TAG.
michael@0 133 */
michael@0 134 #ifndef ALOGW
michael@0 135 #define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
michael@0 136 #endif
michael@0 137
michael@0 138 #ifndef ALOGW_IF
michael@0 139 #define ALOGW_IF(cond, ...) \
michael@0 140 ( (CONDITION(cond)) \
michael@0 141 ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
michael@0 142 : (void)0 )
michael@0 143 #endif
michael@0 144
michael@0 145 /*
michael@0 146 * Simplified macro to send an error log message using the current LOG_TAG.
michael@0 147 */
michael@0 148 #ifndef ALOGE
michael@0 149 #define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
michael@0 150 #endif
michael@0 151
michael@0 152 #ifndef ALOGE_IF
michael@0 153 #define ALOGE_IF(cond, ...) \
michael@0 154 ( (CONDITION(cond)) \
michael@0 155 ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
michael@0 156 : (void)0 )
michael@0 157 #endif
michael@0 158
michael@0 159 // ---------------------------------------------------------------------
michael@0 160
michael@0 161 /*
michael@0 162 * Conditional based on whether the current LOG_TAG is enabled at
michael@0 163 * verbose priority.
michael@0 164 */
michael@0 165 #ifndef IF_ALOGV
michael@0 166 #if LOG_NDEBUG
michael@0 167 #define IF_ALOGV() if (false)
michael@0 168 #else
michael@0 169 #define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG)
michael@0 170 #endif
michael@0 171 #endif
michael@0 172
michael@0 173 /*
michael@0 174 * Conditional based on whether the current LOG_TAG is enabled at
michael@0 175 * debug priority.
michael@0 176 */
michael@0 177 #ifndef IF_ALOGD
michael@0 178 #define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
michael@0 179 #endif
michael@0 180
michael@0 181 /*
michael@0 182 * Conditional based on whether the current LOG_TAG is enabled at
michael@0 183 * info priority.
michael@0 184 */
michael@0 185 #ifndef IF_ALOGI
michael@0 186 #define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG)
michael@0 187 #endif
michael@0 188
michael@0 189 /*
michael@0 190 * Conditional based on whether the current LOG_TAG is enabled at
michael@0 191 * warn priority.
michael@0 192 */
michael@0 193 #ifndef IF_ALOGW
michael@0 194 #define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG)
michael@0 195 #endif
michael@0 196
michael@0 197 /*
michael@0 198 * Conditional based on whether the current LOG_TAG is enabled at
michael@0 199 * error priority.
michael@0 200 */
michael@0 201 #ifndef IF_ALOGE
michael@0 202 #define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
michael@0 203 #endif
michael@0 204
michael@0 205
michael@0 206 // ---------------------------------------------------------------------
michael@0 207
michael@0 208 /*
michael@0 209 * Simplified macro to send a verbose system log message using the current LOG_TAG.
michael@0 210 */
michael@0 211 #ifndef SLOGV
michael@0 212 #if LOG_NDEBUG
michael@0 213 #define SLOGV(...) ((void)0)
michael@0 214 #else
michael@0 215 #define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
michael@0 216 #endif
michael@0 217 #endif
michael@0 218
michael@0 219 #define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
michael@0 220
michael@0 221 #ifndef SLOGV_IF
michael@0 222 #if LOG_NDEBUG
michael@0 223 #define SLOGV_IF(cond, ...) ((void)0)
michael@0 224 #else
michael@0 225 #define SLOGV_IF(cond, ...) \
michael@0 226 ( (CONDITION(cond)) \
michael@0 227 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
michael@0 228 : (void)0 )
michael@0 229 #endif
michael@0 230 #endif
michael@0 231
michael@0 232 /*
michael@0 233 * Simplified macro to send a debug system log message using the current LOG_TAG.
michael@0 234 */
michael@0 235 #ifndef SLOGD
michael@0 236 #define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
michael@0 237 #endif
michael@0 238
michael@0 239 #ifndef SLOGD_IF
michael@0 240 #define SLOGD_IF(cond, ...) \
michael@0 241 ( (CONDITION(cond)) \
michael@0 242 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
michael@0 243 : (void)0 )
michael@0 244 #endif
michael@0 245
michael@0 246 /*
michael@0 247 * Simplified macro to send an info system log message using the current LOG_TAG.
michael@0 248 */
michael@0 249 #ifndef SLOGI
michael@0 250 #define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
michael@0 251 #endif
michael@0 252
michael@0 253 #ifndef SLOGI_IF
michael@0 254 #define SLOGI_IF(cond, ...) \
michael@0 255 ( (CONDITION(cond)) \
michael@0 256 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
michael@0 257 : (void)0 )
michael@0 258 #endif
michael@0 259
michael@0 260 /*
michael@0 261 * Simplified macro to send a warning system log message using the current LOG_TAG.
michael@0 262 */
michael@0 263 #ifndef SLOGW
michael@0 264 #define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
michael@0 265 #endif
michael@0 266
michael@0 267 #ifndef SLOGW_IF
michael@0 268 #define SLOGW_IF(cond, ...) \
michael@0 269 ( (CONDITION(cond)) \
michael@0 270 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
michael@0 271 : (void)0 )
michael@0 272 #endif
michael@0 273
michael@0 274 /*
michael@0 275 * Simplified macro to send an error system log message using the current LOG_TAG.
michael@0 276 */
michael@0 277 #ifndef SLOGE
michael@0 278 #define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
michael@0 279 #endif
michael@0 280
michael@0 281 #ifndef SLOGE_IF
michael@0 282 #define SLOGE_IF(cond, ...) \
michael@0 283 ( (CONDITION(cond)) \
michael@0 284 ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
michael@0 285 : (void)0 )
michael@0 286 #endif
michael@0 287
michael@0 288 // ---------------------------------------------------------------------
michael@0 289
michael@0 290 /*
michael@0 291 * Simplified macro to send a verbose radio log message using the current LOG_TAG.
michael@0 292 */
michael@0 293 #ifndef RLOGV
michael@0 294 #if LOG_NDEBUG
michael@0 295 #define RLOGV(...) ((void)0)
michael@0 296 #else
michael@0 297 #define RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
michael@0 298 #endif
michael@0 299 #endif
michael@0 300
michael@0 301 #define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
michael@0 302
michael@0 303 #ifndef RLOGV_IF
michael@0 304 #if LOG_NDEBUG
michael@0 305 #define RLOGV_IF(cond, ...) ((void)0)
michael@0 306 #else
michael@0 307 #define RLOGV_IF(cond, ...) \
michael@0 308 ( (CONDITION(cond)) \
michael@0 309 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
michael@0 310 : (void)0 )
michael@0 311 #endif
michael@0 312 #endif
michael@0 313
michael@0 314 /*
michael@0 315 * Simplified macro to send a debug radio log message using the current LOG_TAG.
michael@0 316 */
michael@0 317 #ifndef RLOGD
michael@0 318 #define RLOGD(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
michael@0 319 #endif
michael@0 320
michael@0 321 #ifndef RLOGD_IF
michael@0 322 #define RLOGD_IF(cond, ...) \
michael@0 323 ( (CONDITION(cond)) \
michael@0 324 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
michael@0 325 : (void)0 )
michael@0 326 #endif
michael@0 327
michael@0 328 /*
michael@0 329 * Simplified macro to send an info radio log message using the current LOG_TAG.
michael@0 330 */
michael@0 331 #ifndef RLOGI
michael@0 332 #define RLOGI(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
michael@0 333 #endif
michael@0 334
michael@0 335 #ifndef RLOGI_IF
michael@0 336 #define RLOGI_IF(cond, ...) \
michael@0 337 ( (CONDITION(cond)) \
michael@0 338 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
michael@0 339 : (void)0 )
michael@0 340 #endif
michael@0 341
michael@0 342 /*
michael@0 343 * Simplified macro to send a warning radio log message using the current LOG_TAG.
michael@0 344 */
michael@0 345 #ifndef RLOGW
michael@0 346 #define RLOGW(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
michael@0 347 #endif
michael@0 348
michael@0 349 #ifndef RLOGW_IF
michael@0 350 #define RLOGW_IF(cond, ...) \
michael@0 351 ( (CONDITION(cond)) \
michael@0 352 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
michael@0 353 : (void)0 )
michael@0 354 #endif
michael@0 355
michael@0 356 /*
michael@0 357 * Simplified macro to send an error radio log message using the current LOG_TAG.
michael@0 358 */
michael@0 359 #ifndef RLOGE
michael@0 360 #define RLOGE(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
michael@0 361 #endif
michael@0 362
michael@0 363 #ifndef RLOGE_IF
michael@0 364 #define RLOGE_IF(cond, ...) \
michael@0 365 ( (CONDITION(cond)) \
michael@0 366 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
michael@0 367 : (void)0 )
michael@0 368 #endif
michael@0 369
michael@0 370
michael@0 371 // ---------------------------------------------------------------------
michael@0 372
michael@0 373 /*
michael@0 374 * Log a fatal error. If the given condition fails, this stops program
michael@0 375 * execution like a normal assertion, but also generating the given message.
michael@0 376 * It is NOT stripped from release builds. Note that the condition test
michael@0 377 * is -inverted- from the normal assert() semantics.
michael@0 378 */
michael@0 379 #ifndef LOG_ALWAYS_FATAL_IF
michael@0 380 #define LOG_ALWAYS_FATAL_IF(cond, ...) \
michael@0 381 ( (CONDITION(cond)) \
michael@0 382 ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
michael@0 383 : (void)0 )
michael@0 384 #endif
michael@0 385
michael@0 386 #ifndef LOG_ALWAYS_FATAL
michael@0 387 #define LOG_ALWAYS_FATAL(...) \
michael@0 388 ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) )
michael@0 389 #endif
michael@0 390
michael@0 391 /*
michael@0 392 * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
michael@0 393 * are stripped out of release builds.
michael@0 394 */
michael@0 395 #if LOG_NDEBUG
michael@0 396
michael@0 397 #ifndef LOG_FATAL_IF
michael@0 398 #define LOG_FATAL_IF(cond, ...) ((void)0)
michael@0 399 #endif
michael@0 400 #ifndef LOG_FATAL
michael@0 401 #define LOG_FATAL(...) ((void)0)
michael@0 402 #endif
michael@0 403
michael@0 404 #else
michael@0 405
michael@0 406 #ifndef LOG_FATAL_IF
michael@0 407 #define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__)
michael@0 408 #endif
michael@0 409 #ifndef LOG_FATAL
michael@0 410 #define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
michael@0 411 #endif
michael@0 412
michael@0 413 #endif
michael@0 414
michael@0 415 /*
michael@0 416 * Assertion that generates a log message when the assertion fails.
michael@0 417 * Stripped out of release builds. Uses the current LOG_TAG.
michael@0 418 */
michael@0 419 #ifndef ALOG_ASSERT
michael@0 420 #define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
michael@0 421 //#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond)
michael@0 422 #endif
michael@0 423
michael@0 424 // ---------------------------------------------------------------------
michael@0 425
michael@0 426 /*
michael@0 427 * Basic log message macro.
michael@0 428 *
michael@0 429 * Example:
michael@0 430 * ALOG(LOG_WARN, NULL, "Failed with error %d", errno);
michael@0 431 *
michael@0 432 * The second argument may be NULL or "" to indicate the "global" tag.
michael@0 433 */
michael@0 434 #ifndef ALOG
michael@0 435 #define ALOG(priority, tag, ...) \
michael@0 436 LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
michael@0 437 #endif
michael@0 438
michael@0 439 /*
michael@0 440 * Log macro that allows you to specify a number for the priority.
michael@0 441 */
michael@0 442 #ifndef LOG_PRI
michael@0 443 #define LOG_PRI(priority, tag, ...) \
michael@0 444 android_printLog(priority, tag, __VA_ARGS__)
michael@0 445 #endif
michael@0 446
michael@0 447 /*
michael@0 448 * Log macro that allows you to pass in a varargs ("args" is a va_list).
michael@0 449 */
michael@0 450 #ifndef LOG_PRI_VA
michael@0 451 #define LOG_PRI_VA(priority, tag, fmt, args) \
michael@0 452 android_vprintLog(priority, NULL, tag, fmt, args)
michael@0 453 #endif
michael@0 454
michael@0 455 /*
michael@0 456 * Conditional given a desired logging priority and tag.
michael@0 457 */
michael@0 458 #ifndef IF_ALOG
michael@0 459 #define IF_ALOG(priority, tag) \
michael@0 460 if (android_testLog(ANDROID_##priority, tag))
michael@0 461 #endif
michael@0 462
michael@0 463 // ---------------------------------------------------------------------
michael@0 464
michael@0 465 /*
michael@0 466 * Event logging.
michael@0 467 */
michael@0 468
michael@0 469 /*
michael@0 470 * Event log entry types. These must match up with the declarations in
michael@0 471 * java/android/android/util/EventLog.java.
michael@0 472 */
michael@0 473 typedef enum {
michael@0 474 EVENT_TYPE_INT = 0,
michael@0 475 EVENT_TYPE_LONG = 1,
michael@0 476 EVENT_TYPE_STRING = 2,
michael@0 477 EVENT_TYPE_LIST = 3,
michael@0 478 } AndroidEventLogType;
michael@0 479
michael@0 480
michael@0 481 #ifndef LOG_EVENT_INT
michael@0 482 #define LOG_EVENT_INT(_tag, _value) { \
michael@0 483 int intBuf = _value; \
michael@0 484 (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \
michael@0 485 sizeof(intBuf)); \
michael@0 486 }
michael@0 487 #endif
michael@0 488 #ifndef LOG_EVENT_LONG
michael@0 489 #define LOG_EVENT_LONG(_tag, _value) { \
michael@0 490 long long longBuf = _value; \
michael@0 491 (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \
michael@0 492 sizeof(longBuf)); \
michael@0 493 }
michael@0 494 #endif
michael@0 495 #ifndef LOG_EVENT_STRING
michael@0 496 #define LOG_EVENT_STRING(_tag, _value) \
michael@0 497 ((void) 0) /* not implemented -- must combine len with string */
michael@0 498 #endif
michael@0 499 /* TODO: something for LIST */
michael@0 500
michael@0 501 /*
michael@0 502 * ===========================================================================
michael@0 503 *
michael@0 504 * The stuff in the rest of this file should not be used directly.
michael@0 505 */
michael@0 506
michael@0 507 #define android_printLog(prio, tag, fmt...) \
michael@0 508 __android_log_print(prio, tag, fmt)
michael@0 509
michael@0 510 #define android_vprintLog(prio, cond, tag, fmt...) \
michael@0 511 __android_log_vprint(prio, tag, fmt)
michael@0 512
michael@0 513 /* XXX Macros to work around syntax errors in places where format string
michael@0 514 * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
michael@0 515 * (happens only in debug builds).
michael@0 516 */
michael@0 517
michael@0 518 /* Returns 2nd arg. Used to substitute default value if caller's vararg list
michael@0 519 * is empty.
michael@0 520 */
michael@0 521 #define __android_second(dummy, second, ...) second
michael@0 522
michael@0 523 /* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
michael@0 524 * returns nothing.
michael@0 525 */
michael@0 526 #define __android_rest(first, ...) , ## __VA_ARGS__
michael@0 527
michael@0 528 #define android_printAssert(cond, tag, fmt...) \
michael@0 529 __android_log_assert(cond, tag, \
michael@0 530 __android_second(0, ## fmt, NULL) __android_rest(fmt))
michael@0 531
michael@0 532 #define android_writeLog(prio, tag, text) \
michael@0 533 __android_log_write(prio, tag, text)
michael@0 534
michael@0 535 #define android_bWriteLog(tag, payload, len) \
michael@0 536 __android_log_bwrite(tag, payload, len)
michael@0 537 #define android_btWriteLog(tag, type, payload, len) \
michael@0 538 __android_log_btwrite(tag, type, payload, len)
michael@0 539
michael@0 540 // TODO: remove these prototypes and their users
michael@0 541 #define android_testLog(prio, tag) (1)
michael@0 542 #define android_writevLog(vec,num) do{}while(0)
michael@0 543 #define android_write1Log(str,len) do{}while (0)
michael@0 544 #define android_setMinPriority(tag, prio) do{}while(0)
michael@0 545 //#define android_logToCallback(func) do{}while(0)
michael@0 546 #define android_logToFile(tag, file) (0)
michael@0 547 #define android_logToFd(tag, fd) (0)
michael@0 548
michael@0 549 typedef enum {
michael@0 550 LOG_ID_MAIN = 0,
michael@0 551 LOG_ID_RADIO = 1,
michael@0 552 LOG_ID_EVENTS = 2,
michael@0 553 LOG_ID_SYSTEM = 3,
michael@0 554
michael@0 555 LOG_ID_MAX
michael@0 556 } log_id_t;
michael@0 557
michael@0 558 /*
michael@0 559 * Send a simple string to the log.
michael@0 560 */
michael@0 561 int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
michael@0 562 int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...);
michael@0 563
michael@0 564
michael@0 565 #ifdef __cplusplus
michael@0 566 }
michael@0 567 #endif
michael@0 568
michael@0 569 #endif // _LIBS_CUTILS_LOG_H

mercurial