| haohuang | 8e2266a | 2020-09-24 17:18:55 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2014, 2020 The Linux Foundation. All rights reserved. | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 2 | * | 
|  | 3 | * Redistribution and use in source and binary forms, with or without | 
|  | 4 | * modification, are permitted provided that the following conditions are | 
|  | 5 | * met: | 
|  | 6 | *     * Redistributions of source code must retain the above copyright | 
|  | 7 | *       notice, this list of conditions and the following disclaimer. | 
|  | 8 | *     * Redistributions in binary form must reproduce the above | 
|  | 9 | *       copyright notice, this list of conditions and the following | 
|  | 10 | *       disclaimer in the documentation and/or other materials provided | 
|  | 11 | *       with the distribution. | 
| Duy Truong | a987332 | 2013-01-10 08:07:21 -0800 | [diff] [blame] | 12 | *     * Neither the name of The Linux Foundation nor the names of its | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 13 | *       contributors may be used to endorse or promote products derived | 
|  | 14 | *       from this software without specific prior written permission. | 
|  | 15 | * | 
|  | 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | 
|  | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 
|  | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT | 
|  | 19 | * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | 
|  | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
|  | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
|  | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | 
|  | 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 
|  | 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | 
|  | 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | 
|  | 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|  | 27 | * | 
|  | 28 | */ | 
|  | 29 |  | 
|  | 30 | #ifndef __LOG_UTIL_H__ | 
|  | 31 | #define __LOG_UTIL_H__ | 
|  | 32 |  | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 33 | #include <stdbool.h> | 
| Saurabh Srivastava | 3f91528 | 2019-12-18 14:26:29 +0530 | [diff] [blame] | 34 | #include <loc_pla.h> | 
| Harikrishnan Hariharan | 5f583c6 | 2017-09-14 22:50:42 +0530 | [diff] [blame] | 35 | #if defined (USE_ANDROID_LOGGING) || defined (ANDROID) | 
|  | 36 | // Android and LE targets with logcat support | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 37 | #include <utils/Log.h> | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 38 | #include <unistd.h> | 
|  | 39 | #include <sys/syscall.h> | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 40 |  | 
| Harikrishnan Hariharan | 5f583c6 | 2017-09-14 22:50:42 +0530 | [diff] [blame] | 41 | #elif defined (USE_GLIB) | 
|  | 42 | // LE targets with no logcat support | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 43 | #include <stdio.h> | 
| Kevin Tang | 61de97e | 2016-09-12 17:20:55 -0700 | [diff] [blame] | 44 | #include <string.h> | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 45 | #include <sys/types.h> | 
| Kevin Tang | be20768 | 2018-02-15 18:49:42 -0800 | [diff] [blame] | 46 | #include <sys/time.h> | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 47 | #include <unistd.h> | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 48 | #include <sys/syscall.h> | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 49 |  | 
|  | 50 | #ifndef LOG_TAG | 
|  | 51 | #define LOG_TAG "GPS_UTILS" | 
| Kevin Tang | 61de97e | 2016-09-12 17:20:55 -0700 | [diff] [blame] | 52 | #endif /* LOG_TAG */ | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 53 |  | 
| Kevin Tang | be20768 | 2018-02-15 18:49:42 -0800 | [diff] [blame] | 54 | // LE targets with no logcat support | 
| Nilesh Gharde | c8afcf7 | 2020-09-18 13:49:34 +0530 | [diff] [blame] | 55 | #if defined(FEATURE_EXTERNAL_AP) || defined(USE_SYSLOG_LOGGING) | 
| Wei Chen | 1d823b0 | 2018-12-14 16:22:17 -0800 | [diff] [blame] | 56 | #include <syslog.h> | 
|  | 57 | #define ALOGE(...) syslog(LOG_ERR,     "LOC_LOGE: " __VA_ARGS__); | 
|  | 58 | #define ALOGW(...) syslog(LOG_WARNING, "LOC_LOGW: " __VA_ARGS__); | 
|  | 59 | #define ALOGI(...) syslog(LOG_NOTICE,  "LOC_LOGI: " __VA_ARGS__); | 
|  | 60 | #define ALOGD(...) syslog(LOG_DEBUG,   "LOC_LOGD: " __VA_ARGS__); | 
|  | 61 | #define ALOGV(...) syslog(LOG_NOTICE,  "LOC_LOGV: " __VA_ARGS__); | 
|  | 62 | #else /* FEATURE_EXTERNAL_AP */ | 
| Kevin Tang | be20768 | 2018-02-15 18:49:42 -0800 | [diff] [blame] | 63 | #define TS_PRINTF(format, x...)                                  \ | 
|  | 64 | {                                                                \ | 
|  | 65 | struct timeval tv;                                           \ | 
|  | 66 | struct timezone tz;                                          \ | 
|  | 67 | int hh, mm, ss;                                              \ | 
|  | 68 | gettimeofday(&tv, &tz);                                      \ | 
|  | 69 | hh = tv.tv_sec/3600%24;                                      \ | 
|  | 70 | mm = (tv.tv_sec%3600)/60;                                    \ | 
|  | 71 | ss = tv.tv_sec%60;                                           \ | 
|  | 72 | fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec, ##x);    \ | 
|  | 73 | } | 
|  | 74 |  | 
|  | 75 | #define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x) | 
|  | 76 | #define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x) | 
|  | 77 | #define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x) | 
|  | 78 | #define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x) | 
|  | 79 | #define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x) | 
| Wei Chen | 1d823b0 | 2018-12-14 16:22:17 -0800 | [diff] [blame] | 80 | #endif /* FEATURE_EXTERNAL_AP */ | 
| Kevin Tang | be20768 | 2018-02-15 18:49:42 -0800 | [diff] [blame] | 81 |  | 
| Harikrishnan Hariharan | 5f583c6 | 2017-09-14 22:50:42 +0530 | [diff] [blame] | 82 | #endif /* #if defined (USE_ANDROID_LOGGING) || defined (ANDROID) */ | 
| Satheesh Jayakumar | 0590a64 | 2013-05-07 09:25:21 -0700 | [diff] [blame] | 83 |  | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 84 | #ifdef __cplusplus | 
|  | 85 | extern "C" | 
|  | 86 | { | 
|  | 87 | #endif | 
|  | 88 | /*============================================================================= | 
|  | 89 | * | 
|  | 90 | *                         LOC LOGGER TYPE DECLARATION | 
|  | 91 | * | 
|  | 92 | *============================================================================*/ | 
|  | 93 | /* LOC LOGGER */ | 
|  | 94 | typedef struct loc_logger_s | 
|  | 95 | { | 
|  | 96 | unsigned long  DEBUG_LEVEL; | 
|  | 97 | unsigned long  TIMESTAMP; | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 98 | bool           LOG_BUFFER_ENABLE; | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 99 | } loc_logger_s_type; | 
|  | 100 |  | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 101 |  | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 102 | /*============================================================================= | 
|  | 103 | * | 
|  | 104 | *                               EXTERNAL DATA | 
|  | 105 | * | 
|  | 106 | *============================================================================*/ | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 107 |  | 
|  | 108 | // Logging Improvements | 
|  | 109 | extern const char *loc_logger_boolStr[]; | 
|  | 110 |  | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 111 | extern loc_logger_s_type loc_logger; | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 112 | extern const char *boolStr[]; | 
|  | 113 | extern const char VOID_RET[]; | 
|  | 114 | extern const char FROM_AFW[]; | 
|  | 115 | extern const char TO_MODEM[]; | 
|  | 116 | extern const char FROM_MODEM[]; | 
|  | 117 | extern const char TO_AFW[]; | 
|  | 118 | extern const char EXIT_TAG[]; | 
|  | 119 | extern const char ENTRY_TAG[]; | 
| Dante Russo | 1b07337 | 2015-07-02 17:29:29 -0700 | [diff] [blame] | 120 | extern const char EXIT_ERROR_TAG[]; | 
|  | 121 |  | 
| Saurabh Srivastava | 3f91528 | 2019-12-18 14:26:29 +0530 | [diff] [blame] | 122 | #define BUILD_TYPE_PROP_NA 0 | 
|  | 123 | #define BUILD_TYPE_PROP_USER 1 | 
|  | 124 | #define BUILD_TYPE_PROP_USERDEBUG 2 | 
|  | 125 | #define BUILD_TYPE_PROP_INVALID 3 | 
|  | 126 | extern int build_type_prop; | 
|  | 127 |  | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 128 | /*============================================================================= | 
|  | 129 | * | 
|  | 130 | *                        MODULE EXPORTED FUNCTIONS | 
|  | 131 | * | 
|  | 132 | *============================================================================*/ | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 133 | inline void loc_logger_init(unsigned long debug, unsigned long timestamp) | 
|  | 134 | { | 
| Saurabh Srivastava | 3f91528 | 2019-12-18 14:26:29 +0530 | [diff] [blame] | 135 | loc_logger.DEBUG_LEVEL = debug; | 
|  | 136 |  | 
|  | 137 | if (BUILD_TYPE_PROP_NA == build_type_prop) { | 
|  | 138 | char value[PROPERTY_VALUE_MAX] = "NA"; | 
|  | 139 | property_get("ro.build.type", value, "userdebug"); | 
|  | 140 | if (0 == strcmp(value, "user")) { | 
|  | 141 | build_type_prop = BUILD_TYPE_PROP_USER; | 
|  | 142 | } else if (0 == strcmp(value, "userdebug")) { | 
|  | 143 | build_type_prop = BUILD_TYPE_PROP_USERDEBUG; | 
|  | 144 | } else { | 
|  | 145 | build_type_prop = BUILD_TYPE_PROP_INVALID; | 
|  | 146 | } | 
|  | 147 | } | 
|  | 148 |  | 
|  | 149 | if (BUILD_TYPE_PROP_USER == build_type_prop) { | 
|  | 150 | // force user builds to 2 or less | 
|  | 151 | if (loc_logger.DEBUG_LEVEL > 2) { | 
|  | 152 | loc_logger.DEBUG_LEVEL = 2; | 
|  | 153 | } | 
|  | 154 | } | 
|  | 155 |  | 
|  | 156 | loc_logger.TIMESTAMP = timestamp; | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 157 | } | 
|  | 158 |  | 
|  | 159 | inline void log_buffer_init(bool enabled) { | 
|  | 160 | loc_logger.LOG_BUFFER_ENABLE = enabled; | 
|  | 161 | } | 
| haohuang | 8e2266a | 2020-09-24 17:18:55 +0800 | [diff] [blame] | 162 | extern void log_tag_level_map_init(); | 
|  | 163 | extern int get_tag_log_level(const char* tag); | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 164 | extern char* get_timestamp(char* str, unsigned long buf_size); | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 165 | extern void log_buffer_insert(char *str, unsigned long buf_size, int level); | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 166 | /*============================================================================= | 
|  | 167 | * | 
|  | 168 | *                          LOGGING BUFFER MACROS | 
|  | 169 | * | 
|  | 170 | *============================================================================*/ | 
|  | 171 | #ifndef LOG_NDEBUG | 
|  | 172 | #define LOG_NDEBUG 0 | 
|  | 173 | #endif | 
|  | 174 | #define TOTAL_LOG_LEVELS 5 | 
|  | 175 | #define LOGGING_BUFFER_MAX_LEN 1024 | 
|  | 176 | #define IF_LOG_BUFFER_ENABLE if (loc_logger.LOG_BUFFER_ENABLE) | 
|  | 177 | #define INSERT_BUFFER(flag, level, format, x...)                                              \ | 
|  | 178 | {                                                                                             \ | 
|  | 179 | IF_LOG_BUFFER_ENABLE {                                                                    \ | 
|  | 180 | if (flag == 0) {                                                                      \ | 
|  | 181 | char timestr[32];                                                                 \ | 
|  | 182 | get_timestamp(timestr, sizeof(timestr));                                          \ | 
|  | 183 | char log_str[LOGGING_BUFFER_MAX_LEN];                                             \ | 
|  | 184 | snprintf(log_str, LOGGING_BUFFER_MAX_LEN, "%s %d %ld %s :" format "\n",           \ | 
|  | 185 | timestr, getpid(), syscall(SYS_gettid), LOG_TAG==NULL ? "": LOG_TAG, ##x);\ | 
|  | 186 | log_buffer_insert(log_str, sizeof(log_str), level);                               \ | 
|  | 187 | }                                                                                     \ | 
|  | 188 | }                                                                                         \ | 
|  | 189 | } | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 190 |  | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 191 | #ifndef DEBUG_DMN_LOC_API | 
|  | 192 |  | 
|  | 193 | /* LOGGING MACROS */ | 
| Tushar Janefalkar | 6fa0e8a | 2013-06-20 17:24:37 -0700 | [diff] [blame] | 194 | /*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp | 
|  | 195 | if that value remains unchanged, it means gps.conf did not | 
|  | 196 | provide a value and we default to the initial value to use | 
|  | 197 | Android's logging levels*/ | 
| haohuang | 8e2266a | 2020-09-24 17:18:55 +0800 | [diff] [blame] | 198 |  | 
|  | 199 |  | 
|  | 200 | /* Tag based logging control MACROS */ | 
|  | 201 | /* The logic is like this: | 
|  | 202 | * 1, LOCAL_LOG_LEVEL is defined as a static variable in log_util.h, | 
|  | 203 | *    then all source files which includes log_util.h will have its own LOCAL_LOG_LEVEL variable; | 
|  | 204 | * 2, For each source file, | 
|  | 205 | *    2.1, First time when LOC_LOG* is invoked(its LOCAL_LOG_LEVEL == -1), | 
|  | 206 | *         Set the tag based log level according to the <tag, level> map; | 
|  | 207 | *         If this tag isn't found in map, set local debug level as global loc_logger.DEBUG_LEVEL; | 
|  | 208 | *    2.2, If not the first time, use its LOCAL_LOG_LEVEL as the debug level of this tag. | 
|  | 209 | */ | 
|  | 210 | static int LOCAL_LOG_LEVEL = -1; | 
|  | 211 | #define IF_LOC_LOG(x) \ | 
|  | 212 | if (((LOCAL_LOG_LEVEL == -1 && (LOCAL_LOG_LEVEL = get_tag_log_level(LOG_TAG)) >= x) ||\ | 
|  | 213 | LOCAL_LOG_LEVEL >= x) && LOCAL_LOG_LEVEL <= 5) | 
|  | 214 |  | 
|  | 215 | #define IF_LOC_LOGE IF_LOC_LOG(1) | 
|  | 216 | #define IF_LOC_LOGW IF_LOC_LOG(2) | 
|  | 217 | #define IF_LOC_LOGI IF_LOC_LOG(3) | 
|  | 218 | #define IF_LOC_LOGD IF_LOC_LOG(4) | 
|  | 219 | #define IF_LOC_LOGV IF_LOC_LOG(5) | 
| Tushar Janefalkar | 4460543 | 2014-01-15 10:24:26 -0800 | [diff] [blame] | 220 |  | 
| haohuang | d71529a | 2019-09-16 16:03:09 +0800 | [diff] [blame] | 221 | #define LOC_LOGE(...) IF_LOC_LOGE { ALOGE(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 0, __VA_ARGS__);} | 
|  | 222 | #define LOC_LOGW(...) IF_LOC_LOGW { ALOGW(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 1, __VA_ARGS__);} | 
|  | 223 | #define LOC_LOGI(...) IF_LOC_LOGI { ALOGI(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 2, __VA_ARGS__);} | 
|  | 224 | #define LOC_LOGD(...) IF_LOC_LOGD { ALOGD(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 3, __VA_ARGS__);} | 
|  | 225 | #define LOC_LOGV(...) IF_LOC_LOGV { ALOGV(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 4, __VA_ARGS__);} | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 226 |  | 
|  | 227 | #else /* DEBUG_DMN_LOC_API */ | 
|  | 228 |  | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 229 | #define LOC_LOGE(...) ALOGE(__VA_ARGS__) | 
|  | 230 | #define LOC_LOGW(...) ALOGW(__VA_ARGS__) | 
|  | 231 | #define LOC_LOGI(...) ALOGI(__VA_ARGS__) | 
|  | 232 | #define LOC_LOGD(...) ALOGD(__VA_ARGS__) | 
|  | 233 | #define LOC_LOGV(...) ALOGV(__VA_ARGS__) | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 234 |  | 
|  | 235 | #endif /* DEBUG_DMN_LOC_API */ | 
|  | 236 |  | 
|  | 237 | /*============================================================================= | 
|  | 238 | * | 
|  | 239 | *                          LOGGING IMPROVEMENT MACROS | 
|  | 240 | * | 
|  | 241 | *============================================================================*/ | 
|  | 242 | #define LOG_(LOC_LOG, ID, WHAT, SPEC, VAL)                                    \ | 
|  | 243 | do {                                                                      \ | 
|  | 244 | if (loc_logger.TIMESTAMP) {                                           \ | 
|  | 245 | char ts[32];                                                      \ | 
|  | 246 | LOC_LOG("[%s] %s %s line %d " #SPEC,                              \ | 
|  | 247 | get_timestamp(ts, sizeof(ts)), ID, WHAT, __LINE__, VAL); \ | 
|  | 248 | } else {                                                              \ | 
|  | 249 | LOC_LOG("%s %s line %d " #SPEC,                                   \ | 
|  | 250 | ID, WHAT, __LINE__, VAL);                                \ | 
|  | 251 | }                                                                     \ | 
|  | 252 | } while(0) | 
|  | 253 |  | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 254 | #define LOC_LOG_HEAD(fmt) "%s:%d] " fmt | 
|  | 255 | #define LOC_LOGv(fmt,...) LOC_LOGV(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) | 
|  | 256 | #define LOC_LOGw(fmt,...) LOC_LOGW(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) | 
| Katz Yamada | 87c52f1 | 2018-03-20 15:50:53 -0700 | [diff] [blame] | 257 | #define LOC_LOGi(fmt,...) LOC_LOGI(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 258 | #define LOC_LOGd(fmt,...) LOC_LOGD(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) | 
|  | 259 | #define LOC_LOGe(fmt,...) LOC_LOGE(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__) | 
| Ruifeng Xu | d4c4fbf | 2016-04-15 16:09:15 -0700 | [diff] [blame] | 260 |  | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 261 | #define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL) | 
|  | 262 | #define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL) | 
| Dante Russo | 1b07337 | 2015-07-02 17:29:29 -0700 | [diff] [blame] | 263 | #define LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, ID, WHAT, SPEC, VAL) | 
| Wei Chen | ba93fa3 | 2019-09-27 13:16:13 -0700 | [diff] [blame] | 264 | #define LOG_D(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGD, ID, WHAT, SPEC, VAL) | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 265 |  | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 266 | #define ENTRY_LOG() LOG_V(ENTRY_TAG, __FUNCTION__, %s, "") | 
|  | 267 | #define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL) | 
| Dante Russo | 1b07337 | 2015-07-02 17:29:29 -0700 | [diff] [blame] | 268 | #define EXIT_LOG_WITH_ERROR(SPEC, VAL)                       \ | 
|  | 269 | if (VAL != 0) {                                          \ | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 270 | LOG_E(EXIT_ERROR_TAG, __FUNCTION__, SPEC, VAL);          \ | 
| Dante Russo | 1b07337 | 2015-07-02 17:29:29 -0700 | [diff] [blame] | 271 | } else {                                                 \ | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 272 | LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL);                \ | 
| Dante Russo | 1b07337 | 2015-07-02 17:29:29 -0700 | [diff] [blame] | 273 | } | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 274 |  | 
|  | 275 |  | 
|  | 276 | // Used for logging callflow from Android Framework | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 277 | #define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __FUNCTION__, %s, "") | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 278 | // Used for logging callflow to Modem | 
| Kevin Tang | bbbca84 | 2017-01-09 19:17:20 -0800 | [diff] [blame] | 279 | #define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __FUNCTION__, SPEC, VAL) | 
|  | 280 | // Used for logging callflow from Modem(TO_MODEM, __FUNCTION__, %s, "") | 
|  | 281 | #define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __FUNCTION__, SPEC, VAL) | 
| Wei Chen | ba93fa3 | 2019-09-27 13:16:13 -0700 | [diff] [blame] | 282 | // Used for logging high frequency callflow from Modem(TO_MODEM, __FUNCTION__, %s, "") | 
|  | 283 | #define MODEM_LOG_CALLFLOW_DEBUG(SPEC, VAL) LOG_D(FROM_MODEM, __FUNCTION__, SPEC, VAL) | 
| Dante Russo | 3c2630e | 2012-07-12 18:31:41 -0700 | [diff] [blame] | 284 | // Used for logging callflow to Android Framework | 
|  | 285 | #define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL) | 
|  | 286 |  | 
|  | 287 | #ifdef __cplusplus | 
|  | 288 | } | 
|  | 289 | #endif | 
|  | 290 |  | 
|  | 291 | #endif // __LOG_UTIL_H__ |