log_radio.h revision c89fea44accab8c95cf9b7d74c265439963fbd8a
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/* 42 * Simplified macro to send a verbose radio log message using current LOG_TAG. 43 */ 44#ifndef RLOGV 45#define __RLOGV(...) \ 46 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) 47#if LOG_NDEBUG 48#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0) 49#else 50#define RLOGV(...) __RLOGV(__VA_ARGS__) 51#endif 52#endif 53 54#ifndef RLOGV_IF 55#if LOG_NDEBUG 56#define RLOGV_IF(cond, ...) ((void)0) 57#else 58#define RLOGV_IF(cond, ...) \ 59 ( (__predict_false(cond)) \ 60 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ 61 : (void)0 ) 62#endif 63#endif 64 65/* 66 * Simplified macro to send a debug radio log message using current LOG_TAG. 67 */ 68#ifndef RLOGD 69#define RLOGD(...) \ 70 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) 71#endif 72 73#ifndef RLOGD_IF 74#define RLOGD_IF(cond, ...) \ 75 ( (__predict_false(cond)) \ 76 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ 77 : (void)0 ) 78#endif 79 80/* 81 * Simplified macro to send an info radio log message using current LOG_TAG. 82 */ 83#ifndef RLOGI 84#define RLOGI(...) \ 85 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) 86#endif 87 88#ifndef RLOGI_IF 89#define RLOGI_IF(cond, ...) \ 90 ( (__predict_false(cond)) \ 91 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ 92 : (void)0 ) 93#endif 94 95/* 96 * Simplified macro to send a warning radio log message using current LOG_TAG. 97 */ 98#ifndef RLOGW 99#define RLOGW(...) \ 100 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) 101#endif 102 103#ifndef RLOGW_IF 104#define RLOGW_IF(cond, ...) \ 105 ( (__predict_false(cond)) \ 106 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ 107 : (void)0 ) 108#endif 109 110/* 111 * Simplified macro to send an error radio log message using current LOG_TAG. 112 */ 113#ifndef RLOGE 114#define RLOGE(...) \ 115 ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) 116#endif 117 118#ifndef RLOGE_IF 119#define RLOGE_IF(cond, ...) \ 120 ( (__predict_false(cond)) \ 121 ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ 122 : (void)0 ) 123#endif 124 125#endif /* _LIBS_LOG_LOG_RADIO_H */ 126