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