widget/gonk/libui/cutils_log.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libui/cutils_log.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,569 @@
     1.4 +/*
     1.5 + * Copyright (C) 2005 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +//
    1.21 +// C/C++ logging functions.  See the logging documentation for API details.
    1.22 +//
    1.23 +// We'd like these to be available from C code (in case we import some from
    1.24 +// somewhere), so this has a C interface.
    1.25 +//
    1.26 +// The output will be correct when the log file is shared between multiple
    1.27 +// threads and/or multiple processes so long as the operating system
    1.28 +// supports O_APPEND.  These calls have mutex-protected data structures
    1.29 +// and so are NOT reentrant.  Do not use LOG in a signal handler.
    1.30 +//
    1.31 +#if !defined(_LIBS_CUTILS_LOG_H) && !defined(_LIBS_LOG_LOG_H)
    1.32 +#define _LIBS_LOG_LOG_H
    1.33 +#define _LIBS_CUTILS_LOG_H
    1.34 +
    1.35 +#include <stdio.h>
    1.36 +#include <time.h>
    1.37 +#include <sys/types.h>
    1.38 +#include <unistd.h>
    1.39 +#ifdef HAVE_PTHREADS
    1.40 +#include <pthread.h>
    1.41 +#endif
    1.42 +#include <stdarg.h>
    1.43 +
    1.44 +#if ANDROID_VERSION >= 19
    1.45 +#include <log/uio.h>
    1.46 +#include <log/logd.h>
    1.47 +#else
    1.48 +#include <cutils/uio.h>
    1.49 +#include <cutils/logd.h>
    1.50 +#endif
    1.51 +
    1.52 +#ifdef __cplusplus
    1.53 +extern "C" {
    1.54 +#endif
    1.55 +
    1.56 +// ---------------------------------------------------------------------
    1.57 +
    1.58 +/*
    1.59 + * Normally we strip ALOGV (VERBOSE messages) from release builds.
    1.60 + * You can modify this (for example with "#define LOG_NDEBUG 0"
    1.61 + * at the top of your source file) to change that behavior.
    1.62 + */
    1.63 +#ifndef LOG_NDEBUG
    1.64 +#ifdef NDEBUG
    1.65 +#define LOG_NDEBUG 1
    1.66 +#else
    1.67 +#define LOG_NDEBUG 0
    1.68 +#endif
    1.69 +#endif
    1.70 +
    1.71 +/*
    1.72 + * This is the local tag used for the following simplified
    1.73 + * logging macros.  You can change this preprocessor definition
    1.74 + * before using the other macros to change the tag.
    1.75 + */
    1.76 +#ifndef LOG_TAG
    1.77 +#define LOG_TAG NULL
    1.78 +#endif
    1.79 +
    1.80 +// ---------------------------------------------------------------------
    1.81 +
    1.82 +/*
    1.83 + * Simplified macro to send a verbose log message using the current LOG_TAG.
    1.84 + */
    1.85 +#ifndef ALOGV
    1.86 +#if LOG_NDEBUG
    1.87 +#define ALOGV(...)   ((void)0)
    1.88 +#else
    1.89 +#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
    1.90 +#endif
    1.91 +#endif
    1.92 +
    1.93 +#define CONDITION(cond)     (__builtin_expect((cond)!=0, 0))
    1.94 +
    1.95 +#ifndef ALOGV_IF
    1.96 +#if LOG_NDEBUG
    1.97 +#define ALOGV_IF(cond, ...)   ((void)0)
    1.98 +#else
    1.99 +#define ALOGV_IF(cond, ...) \
   1.100 +    ( (CONDITION(cond)) \
   1.101 +    ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
   1.102 +    : (void)0 )
   1.103 +#endif
   1.104 +#endif
   1.105 +
   1.106 +/*
   1.107 + * Simplified macro to send a debug log message using the current LOG_TAG.
   1.108 + */
   1.109 +#ifndef ALOGD
   1.110 +#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
   1.111 +#endif
   1.112 +
   1.113 +#ifndef ALOGD_IF
   1.114 +#define ALOGD_IF(cond, ...) \
   1.115 +    ( (CONDITION(cond)) \
   1.116 +    ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
   1.117 +    : (void)0 )
   1.118 +#endif
   1.119 +
   1.120 +/*
   1.121 + * Simplified macro to send an info log message using the current LOG_TAG.
   1.122 + */
   1.123 +#ifndef ALOGI
   1.124 +#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
   1.125 +#endif
   1.126 +
   1.127 +#ifndef ALOGI_IF
   1.128 +#define ALOGI_IF(cond, ...) \
   1.129 +    ( (CONDITION(cond)) \
   1.130 +    ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
   1.131 +    : (void)0 )
   1.132 +#endif
   1.133 +
   1.134 +/*
   1.135 + * Simplified macro to send a warning log message using the current LOG_TAG.
   1.136 + */
   1.137 +#ifndef ALOGW
   1.138 +#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
   1.139 +#endif
   1.140 +
   1.141 +#ifndef ALOGW_IF
   1.142 +#define ALOGW_IF(cond, ...) \
   1.143 +    ( (CONDITION(cond)) \
   1.144 +    ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
   1.145 +    : (void)0 )
   1.146 +#endif
   1.147 +
   1.148 +/*
   1.149 + * Simplified macro to send an error log message using the current LOG_TAG.
   1.150 + */
   1.151 +#ifndef ALOGE
   1.152 +#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
   1.153 +#endif
   1.154 +
   1.155 +#ifndef ALOGE_IF
   1.156 +#define ALOGE_IF(cond, ...) \
   1.157 +    ( (CONDITION(cond)) \
   1.158 +    ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
   1.159 +    : (void)0 )
   1.160 +#endif
   1.161 +
   1.162 +// ---------------------------------------------------------------------
   1.163 +
   1.164 +/*
   1.165 + * Conditional based on whether the current LOG_TAG is enabled at
   1.166 + * verbose priority.
   1.167 + */
   1.168 +#ifndef IF_ALOGV
   1.169 +#if LOG_NDEBUG
   1.170 +#define IF_ALOGV() if (false)
   1.171 +#else
   1.172 +#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG)
   1.173 +#endif
   1.174 +#endif
   1.175 +
   1.176 +/*
   1.177 + * Conditional based on whether the current LOG_TAG is enabled at
   1.178 + * debug priority.
   1.179 + */
   1.180 +#ifndef IF_ALOGD
   1.181 +#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
   1.182 +#endif
   1.183 +
   1.184 +/*
   1.185 + * Conditional based on whether the current LOG_TAG is enabled at
   1.186 + * info priority.
   1.187 + */
   1.188 +#ifndef IF_ALOGI
   1.189 +#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG)
   1.190 +#endif
   1.191 +
   1.192 +/*
   1.193 + * Conditional based on whether the current LOG_TAG is enabled at
   1.194 + * warn priority.
   1.195 + */
   1.196 +#ifndef IF_ALOGW
   1.197 +#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG)
   1.198 +#endif
   1.199 +
   1.200 +/*
   1.201 + * Conditional based on whether the current LOG_TAG is enabled at
   1.202 + * error priority.
   1.203 + */
   1.204 +#ifndef IF_ALOGE
   1.205 +#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
   1.206 +#endif
   1.207 +
   1.208 +
   1.209 +// ---------------------------------------------------------------------
   1.210 +
   1.211 +/*
   1.212 + * Simplified macro to send a verbose system log message using the current LOG_TAG.
   1.213 + */
   1.214 +#ifndef SLOGV
   1.215 +#if LOG_NDEBUG
   1.216 +#define SLOGV(...)   ((void)0)
   1.217 +#else
   1.218 +#define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
   1.219 +#endif
   1.220 +#endif
   1.221 +
   1.222 +#define CONDITION(cond)     (__builtin_expect((cond)!=0, 0))
   1.223 +
   1.224 +#ifndef SLOGV_IF
   1.225 +#if LOG_NDEBUG
   1.226 +#define SLOGV_IF(cond, ...)   ((void)0)
   1.227 +#else
   1.228 +#define SLOGV_IF(cond, ...) \
   1.229 +    ( (CONDITION(cond)) \
   1.230 +    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
   1.231 +    : (void)0 )
   1.232 +#endif
   1.233 +#endif
   1.234 +
   1.235 +/*
   1.236 + * Simplified macro to send a debug system log message using the current LOG_TAG.
   1.237 + */
   1.238 +#ifndef SLOGD
   1.239 +#define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
   1.240 +#endif
   1.241 +
   1.242 +#ifndef SLOGD_IF
   1.243 +#define SLOGD_IF(cond, ...) \
   1.244 +    ( (CONDITION(cond)) \
   1.245 +    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
   1.246 +    : (void)0 )
   1.247 +#endif
   1.248 +
   1.249 +/*
   1.250 + * Simplified macro to send an info system log message using the current LOG_TAG.
   1.251 + */
   1.252 +#ifndef SLOGI
   1.253 +#define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
   1.254 +#endif
   1.255 +
   1.256 +#ifndef SLOGI_IF
   1.257 +#define SLOGI_IF(cond, ...) \
   1.258 +    ( (CONDITION(cond)) \
   1.259 +    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
   1.260 +    : (void)0 )
   1.261 +#endif
   1.262 +
   1.263 +/*
   1.264 + * Simplified macro to send a warning system log message using the current LOG_TAG.
   1.265 + */
   1.266 +#ifndef SLOGW
   1.267 +#define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
   1.268 +#endif
   1.269 +
   1.270 +#ifndef SLOGW_IF
   1.271 +#define SLOGW_IF(cond, ...) \
   1.272 +    ( (CONDITION(cond)) \
   1.273 +    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
   1.274 +    : (void)0 )
   1.275 +#endif
   1.276 +
   1.277 +/*
   1.278 + * Simplified macro to send an error system log message using the current LOG_TAG.
   1.279 + */
   1.280 +#ifndef SLOGE
   1.281 +#define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
   1.282 +#endif
   1.283 +
   1.284 +#ifndef SLOGE_IF
   1.285 +#define SLOGE_IF(cond, ...) \
   1.286 +    ( (CONDITION(cond)) \
   1.287 +    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
   1.288 +    : (void)0 )
   1.289 +#endif
   1.290 +
   1.291 +// ---------------------------------------------------------------------
   1.292 +
   1.293 +/*
   1.294 + * Simplified macro to send a verbose radio log message using the current LOG_TAG.
   1.295 + */
   1.296 +#ifndef RLOGV
   1.297 +#if LOG_NDEBUG
   1.298 +#define RLOGV(...)   ((void)0)
   1.299 +#else
   1.300 +#define RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
   1.301 +#endif
   1.302 +#endif
   1.303 +
   1.304 +#define CONDITION(cond)     (__builtin_expect((cond)!=0, 0))
   1.305 +
   1.306 +#ifndef RLOGV_IF
   1.307 +#if LOG_NDEBUG
   1.308 +#define RLOGV_IF(cond, ...)   ((void)0)
   1.309 +#else
   1.310 +#define RLOGV_IF(cond, ...) \
   1.311 +    ( (CONDITION(cond)) \
   1.312 +    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
   1.313 +    : (void)0 )
   1.314 +#endif
   1.315 +#endif
   1.316 +
   1.317 +/*
   1.318 + * Simplified macro to send a debug radio log message using the current LOG_TAG.
   1.319 + */
   1.320 +#ifndef RLOGD
   1.321 +#define RLOGD(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
   1.322 +#endif
   1.323 +
   1.324 +#ifndef RLOGD_IF
   1.325 +#define RLOGD_IF(cond, ...) \
   1.326 +    ( (CONDITION(cond)) \
   1.327 +    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
   1.328 +    : (void)0 )
   1.329 +#endif
   1.330 +
   1.331 +/*
   1.332 + * Simplified macro to send an info radio log message using the current LOG_TAG.
   1.333 + */
   1.334 +#ifndef RLOGI
   1.335 +#define RLOGI(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
   1.336 +#endif
   1.337 +
   1.338 +#ifndef RLOGI_IF
   1.339 +#define RLOGI_IF(cond, ...) \
   1.340 +    ( (CONDITION(cond)) \
   1.341 +    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
   1.342 +    : (void)0 )
   1.343 +#endif
   1.344 +
   1.345 +/*
   1.346 + * Simplified macro to send a warning radio log message using the current LOG_TAG.
   1.347 + */
   1.348 +#ifndef RLOGW
   1.349 +#define RLOGW(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
   1.350 +#endif
   1.351 +
   1.352 +#ifndef RLOGW_IF
   1.353 +#define RLOGW_IF(cond, ...) \
   1.354 +    ( (CONDITION(cond)) \
   1.355 +    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
   1.356 +    : (void)0 )
   1.357 +#endif
   1.358 +
   1.359 +/*
   1.360 + * Simplified macro to send an error radio log message using the current LOG_TAG.
   1.361 + */
   1.362 +#ifndef RLOGE
   1.363 +#define RLOGE(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
   1.364 +#endif
   1.365 +
   1.366 +#ifndef RLOGE_IF
   1.367 +#define RLOGE_IF(cond, ...) \
   1.368 +    ( (CONDITION(cond)) \
   1.369 +    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
   1.370 +    : (void)0 )
   1.371 +#endif
   1.372 +
   1.373 +
   1.374 +// ---------------------------------------------------------------------
   1.375 +
   1.376 +/*
   1.377 + * Log a fatal error.  If the given condition fails, this stops program
   1.378 + * execution like a normal assertion, but also generating the given message.
   1.379 + * It is NOT stripped from release builds.  Note that the condition test
   1.380 + * is -inverted- from the normal assert() semantics.
   1.381 + */
   1.382 +#ifndef LOG_ALWAYS_FATAL_IF
   1.383 +#define LOG_ALWAYS_FATAL_IF(cond, ...) \
   1.384 +    ( (CONDITION(cond)) \
   1.385 +    ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
   1.386 +    : (void)0 )
   1.387 +#endif
   1.388 +
   1.389 +#ifndef LOG_ALWAYS_FATAL
   1.390 +#define LOG_ALWAYS_FATAL(...) \
   1.391 +    ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) )
   1.392 +#endif
   1.393 +
   1.394 +/*
   1.395 + * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
   1.396 + * are stripped out of release builds.
   1.397 + */
   1.398 +#if LOG_NDEBUG
   1.399 +
   1.400 +#ifndef LOG_FATAL_IF
   1.401 +#define LOG_FATAL_IF(cond, ...) ((void)0)
   1.402 +#endif
   1.403 +#ifndef LOG_FATAL
   1.404 +#define LOG_FATAL(...) ((void)0)
   1.405 +#endif
   1.406 +
   1.407 +#else
   1.408 +
   1.409 +#ifndef LOG_FATAL_IF
   1.410 +#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__)
   1.411 +#endif
   1.412 +#ifndef LOG_FATAL
   1.413 +#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
   1.414 +#endif
   1.415 +
   1.416 +#endif
   1.417 +
   1.418 +/*
   1.419 + * Assertion that generates a log message when the assertion fails.
   1.420 + * Stripped out of release builds.  Uses the current LOG_TAG.
   1.421 + */
   1.422 +#ifndef ALOG_ASSERT
   1.423 +#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
   1.424 +//#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond)
   1.425 +#endif
   1.426 +
   1.427 +// ---------------------------------------------------------------------
   1.428 +
   1.429 +/*
   1.430 + * Basic log message macro.
   1.431 + *
   1.432 + * Example:
   1.433 + *  ALOG(LOG_WARN, NULL, "Failed with error %d", errno);
   1.434 + *
   1.435 + * The second argument may be NULL or "" to indicate the "global" tag.
   1.436 + */
   1.437 +#ifndef ALOG
   1.438 +#define ALOG(priority, tag, ...) \
   1.439 +    LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
   1.440 +#endif
   1.441 +
   1.442 +/*
   1.443 + * Log macro that allows you to specify a number for the priority.
   1.444 + */
   1.445 +#ifndef LOG_PRI
   1.446 +#define LOG_PRI(priority, tag, ...) \
   1.447 +    android_printLog(priority, tag, __VA_ARGS__)
   1.448 +#endif
   1.449 +
   1.450 +/*
   1.451 + * Log macro that allows you to pass in a varargs ("args" is a va_list).
   1.452 + */
   1.453 +#ifndef LOG_PRI_VA
   1.454 +#define LOG_PRI_VA(priority, tag, fmt, args) \
   1.455 +    android_vprintLog(priority, NULL, tag, fmt, args)
   1.456 +#endif
   1.457 +
   1.458 +/*
   1.459 + * Conditional given a desired logging priority and tag.
   1.460 + */
   1.461 +#ifndef IF_ALOG
   1.462 +#define IF_ALOG(priority, tag) \
   1.463 +    if (android_testLog(ANDROID_##priority, tag))
   1.464 +#endif
   1.465 +
   1.466 +// ---------------------------------------------------------------------
   1.467 +
   1.468 +/*
   1.469 + * Event logging.
   1.470 + */
   1.471 +
   1.472 +/*
   1.473 + * Event log entry types.  These must match up with the declarations in
   1.474 + * java/android/android/util/EventLog.java.
   1.475 + */
   1.476 +typedef enum {
   1.477 +    EVENT_TYPE_INT      = 0,
   1.478 +    EVENT_TYPE_LONG     = 1,
   1.479 +    EVENT_TYPE_STRING   = 2,
   1.480 +    EVENT_TYPE_LIST     = 3,
   1.481 +} AndroidEventLogType;
   1.482 +
   1.483 +
   1.484 +#ifndef LOG_EVENT_INT
   1.485 +#define LOG_EVENT_INT(_tag, _value) {                                       \
   1.486 +        int intBuf = _value;                                                \
   1.487 +        (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf,            \
   1.488 +            sizeof(intBuf));                                                \
   1.489 +    }
   1.490 +#endif
   1.491 +#ifndef LOG_EVENT_LONG
   1.492 +#define LOG_EVENT_LONG(_tag, _value) {                                      \
   1.493 +        long long longBuf = _value;                                         \
   1.494 +        (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf,          \
   1.495 +            sizeof(longBuf));                                               \
   1.496 +    }
   1.497 +#endif
   1.498 +#ifndef LOG_EVENT_STRING
   1.499 +#define LOG_EVENT_STRING(_tag, _value)                                      \
   1.500 +    ((void) 0)  /* not implemented -- must combine len with string */
   1.501 +#endif
   1.502 +/* TODO: something for LIST */
   1.503 +
   1.504 +/*
   1.505 + * ===========================================================================
   1.506 + *
   1.507 + * The stuff in the rest of this file should not be used directly.
   1.508 + */
   1.509 +
   1.510 +#define android_printLog(prio, tag, fmt...) \
   1.511 +    __android_log_print(prio, tag, fmt)
   1.512 +
   1.513 +#define android_vprintLog(prio, cond, tag, fmt...) \
   1.514 +    __android_log_vprint(prio, tag, fmt)
   1.515 +
   1.516 +/* XXX Macros to work around syntax errors in places where format string
   1.517 + * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
   1.518 + * (happens only in debug builds).
   1.519 + */
   1.520 +
   1.521 +/* Returns 2nd arg.  Used to substitute default value if caller's vararg list
   1.522 + * is empty.
   1.523 + */
   1.524 +#define __android_second(dummy, second, ...)     second
   1.525 +
   1.526 +/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
   1.527 + * returns nothing.
   1.528 + */
   1.529 +#define __android_rest(first, ...)               , ## __VA_ARGS__
   1.530 +
   1.531 +#define android_printAssert(cond, tag, fmt...) \
   1.532 +    __android_log_assert(cond, tag, \
   1.533 +        __android_second(0, ## fmt, NULL) __android_rest(fmt))
   1.534 +
   1.535 +#define android_writeLog(prio, tag, text) \
   1.536 +    __android_log_write(prio, tag, text)
   1.537 +
   1.538 +#define android_bWriteLog(tag, payload, len) \
   1.539 +    __android_log_bwrite(tag, payload, len)
   1.540 +#define android_btWriteLog(tag, type, payload, len) \
   1.541 +    __android_log_btwrite(tag, type, payload, len)
   1.542 +
   1.543 +// TODO: remove these prototypes and their users
   1.544 +#define android_testLog(prio, tag) (1)
   1.545 +#define android_writevLog(vec,num) do{}while(0)
   1.546 +#define android_write1Log(str,len) do{}while (0)
   1.547 +#define android_setMinPriority(tag, prio) do{}while(0)
   1.548 +//#define android_logToCallback(func) do{}while(0)
   1.549 +#define android_logToFile(tag, file) (0)
   1.550 +#define android_logToFd(tag, fd) (0)
   1.551 +
   1.552 +typedef enum {
   1.553 +    LOG_ID_MAIN = 0,
   1.554 +    LOG_ID_RADIO = 1,
   1.555 +    LOG_ID_EVENTS = 2,
   1.556 +    LOG_ID_SYSTEM = 3,
   1.557 +
   1.558 +    LOG_ID_MAX
   1.559 +} log_id_t;
   1.560 +
   1.561 +/*
   1.562 + * Send a simple string to the log.
   1.563 + */
   1.564 +int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
   1.565 +int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...);
   1.566 +
   1.567 +
   1.568 +#ifdef __cplusplus
   1.569 +}
   1.570 +#endif
   1.571 +
   1.572 +#endif // _LIBS_CUTILS_LOG_H

mercurial