log_radio.h revision 62d0d2d683f5d19cf9d451548bd03c4b4f53c42e
1/* 2 * Copyright (C) 2005-2017 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#ifndef _LIBS_LOG_LOG_RADIO_H 18#define _LIBS_LOG_LOG_RADIO_H 19 20#include <android/log.h> 21#include <log/log_id.h> 22 23/* 24 * Normally we strip the effects of ALOGV (VERBOSE messages), 25 * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the 26 * release builds be defining NDEBUG. You can modify this (for 27 * example with "#define LOG_NDEBUG 0" at the top of your source 28 * file) to change that behavior. 29 */ 30 31#ifndef LOG_NDEBUG 32#ifdef NDEBUG 33#define LOG_NDEBUG 1 34#else 35#define LOG_NDEBUG 0 36#endif 37#endif 38 39/* --------------------------------------------------------------------- */ 40 41#ifndef __predict_false 42#define __predict_false(exp) __builtin_expect((exp) != 0, 0) 43#endif 44 45/* 46 * Simplified macro to send a verbose radio log message using current LOG_TAG. 47 */ 48#ifndef RLOGV 49#define __RLOGV(...) \ 50 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) 51#if LOG_NDEBUG 52#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0) 53#else 54#define RLOGV(...) __RLOGV(__VA_ARGS__) 55#endif 56#endif 57 58#ifndef RLOGV_IF 59#if LOG_NDEBUG 60#define RLOGV_IF(cond, ...) ((void)0) 61#else 62#define RLOGV_IF(cond, ...) \ 63 ( (__predict_false(cond)) \ 64 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ 65 : (void)0 ) 66#endif 67#endif 68 69/* 70 * Simplified macro to send a debug radio log message using current LOG_TAG. 71 */ 72#ifndef RLOGD 73#define RLOGD(...) \ 74 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) 75#endif 76 77#ifndef RLOGD_IF 78#define RLOGD_IF(cond, ...) \ 79 ( (__predict_false(cond)) \ 80 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ 81 : (void)0 ) 82#endif 83 84/* 85 * Simplified macro to send an info radio log message using current LOG_TAG. 86 */ 87#ifndef RLOGI 88#define RLOGI(...) \ 89 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) 90#endif 91 92#ifndef RLOGI_IF 93#define RLOGI_IF(cond, ...) \ 94 ( (__predict_false(cond)) \ 95 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ 96 : (void)0 ) 97#endif 98 99/* 100 * Simplified macro to send a warning radio log message using current LOG_TAG. 101 */ 102#ifndef RLOGW 103#define RLOGW(...) \ 104 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) 105#endif 106 107#ifndef RLOGW_IF 108#define RLOGW_IF(cond, ...) \ 109 ( (__predict_false(cond)) \ 110 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ 111 : (void)0 ) 112#endif 113 114/* 115 * Simplified macro to send an error radio log message using current LOG_TAG. 116 */ 117#ifndef RLOGE 118#define RLOGE(...) \ 119 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) 120#endif 121 122#ifndef RLOGE_IF 123#define RLOGE_IF(cond, ...) \ 124 ( (__predict_false(cond)) \ 125 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ 126 : (void)0 ) 127#endif 128 129#endif /* _LIBS_LOG_LOG_RADIO_H */ 130