1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 13 #pragma once 14 15 #include <stdarg.h> 16 #include <stdbool.h> 17 #include <stdint.h> 18 #include <stdio.h> 19 20 #include "android/utils/compiler.h" 21 #include "android/utils/log_severity.h" 22 23 ANDROID_BEGIN_HEADER 24 25 #define VERBOSE_TAG_LIST \ 26 _VERBOSE_TAG(init, "emulator initialization") \ 27 _VERBOSE_TAG(console, "control console") \ 28 _VERBOSE_TAG(modem, "emulated GSM modem") \ 29 _VERBOSE_TAG(radio, "emulated GSM AT Command channel") \ 30 _VERBOSE_TAG(keys, "key bindings & presses") \ 31 _VERBOSE_TAG(events, "events sent to the emulator") \ 32 _VERBOSE_TAG(slirp, "internal router/firewall") \ 33 _VERBOSE_TAG(timezone, "host timezone detection") \ 34 _VERBOSE_TAG(socket, "network sockets") \ 35 _VERBOSE_TAG(proxy, "network proxy support") \ 36 _VERBOSE_TAG(audio, "audio sub-system") \ 37 _VERBOSE_TAG(audioin, "audio input backend") \ 38 _VERBOSE_TAG(audioout, "audio output backend") \ 39 _VERBOSE_TAG(surface, "video surface support") \ 40 _VERBOSE_TAG(qemud, "qemud multiplexer daemon") \ 41 _VERBOSE_TAG(gps, "emulated GPS") \ 42 _VERBOSE_TAG(nand_limits, "nand/flash read/write thresholding") \ 43 _VERBOSE_TAG(hw_control, "emulated power/flashlight/led/vibrator") \ 44 _VERBOSE_TAG(avd_config, "android virtual device configuration") \ 45 _VERBOSE_TAG(sensors, "emulated sensors") \ 46 _VERBOSE_TAG(memcheck, "memory checker") \ 47 _VERBOSE_TAG(camera, "camera") \ 48 _VERBOSE_TAG(adevice, "android device connected via port forwarding") \ 49 _VERBOSE_TAG(sensors_port, "sensors emulator connected to android device") \ 50 _VERBOSE_TAG(mtport, "multi-touch emulator connected to android device") \ 51 _VERBOSE_TAG(mtscreen, "multi-touch screen emulation") \ 52 _VERBOSE_TAG(gles, "hardware OpenGLES emulation") \ 53 _VERBOSE_TAG(gles1emu, "emulated GLESv1 renderer") \ 54 _VERBOSE_TAG(adbserver, "ADB server") \ 55 _VERBOSE_TAG(adbclient, "ADB QEMU client") \ 56 _VERBOSE_TAG(adb, "ADB debugger") \ 57 _VERBOSE_TAG(asconnector, "Asynchronous socket connector") \ 58 _VERBOSE_TAG(asyncsocket, "Asynchronous socket") \ 59 _VERBOSE_TAG(sdkctlsocket, "Socket tethering to SdkControl server") \ 60 _VERBOSE_TAG(updater, "Update checker") \ 61 _VERBOSE_TAG(metrics, "Metrics reporting") \ 62 _VERBOSE_TAG(rotation, "Device rotation debugging") \ 63 _VERBOSE_TAG(goldfishsync, "Goldfish Sync Device") \ 64 _VERBOSE_TAG(syncthreads, "HostGPU Sync Threads") \ 65 _VERBOSE_TAG(memory, "Memory Usage Report") \ 66 _VERBOSE_TAG(car, "Emulated car data") \ 67 _VERBOSE_TAG(record, "Screen recording") \ 68 _VERBOSE_TAG(snapshot, "Snapshots") \ 69 _VERBOSE_TAG(virtualscene, "Virtual scene rendering") \ 70 _VERBOSE_TAG(automation, "Automation") \ 71 _VERBOSE_TAG(offworld, "Offworld") \ 72 _VERBOSE_TAG(videoinjection, "Video injection") \ 73 _VERBOSE_TAG(foldable, "Foldable Device") \ 74 _VERBOSE_TAG(curl, "Libcurl requests") \ 75 _VERBOSE_TAG(car_rotary, "Car rotary controller") \ 76 _VERBOSE_TAG(wifi, "Virtio Wifi") \ 77 _VERBOSE_TAG(tvremote, "TV remote") \ 78 _VERBOSE_TAG(time, "Prefix a timestamp when logging") \ 79 _VERBOSE_TAG(ini, "Log details around ini files.") \ 80 _VERBOSE_TAG(bluetooth, "Log bluetooth details.") \ 81 _VERBOSE_TAG(log, "Include timestamp, thread and location in logs") 82 83 #define _VERBOSE_TAG(x, y) VERBOSE_##x, 84 typedef enum { 85 VERBOSE_TAG_LIST VERBOSE_MAX /* do not remove */ 86 } VerboseTag; 87 #undef _VERBOSE_TAG 88 89 extern uint64_t android_verbose; 90 91 // Enable/disable verbose logs from the base/* family. 92 extern void base_enable_verbose_logs(); 93 extern void base_disable_verbose_logs(); 94 #define VERBOSE_ENABLE(tag) android_verbose |= (1ULL << VERBOSE_##tag) 95 96 #define VERBOSE_DISABLE(tag) android_verbose &= (1ULL << VERBOSE_##tag) 97 98 #define VERBOSE_CHECK(tag) ((android_verbose & (1ULL << VERBOSE_##tag)) != 0) 99 100 #define VERBOSE_CHECK_ANY() (android_verbose != 0) 101 102 extern void __emu_log_print(LogSeverity prio, 103 const char* file, 104 int line, 105 const char* fmt, 106 ...); 107 108 #ifndef EMULOG 109 #define EMULOG(priority, fmt, ...) \ 110 __emu_log_print(priority, __FILE__, __LINE__, fmt, ##__VA_ARGS__); 111 #endif 112 113 #define VERBOSE_PRINT(tag, ...) \ 114 if (VERBOSE_CHECK(tag)) { \ 115 EMULOG(EMULATOR_LOG_VERBOSE, ##__VA_ARGS__); \ 116 } 117 118 #define VERBOSE_INFO(tag, ...) \ 119 if (VERBOSE_CHECK(tag)) { \ 120 EMULOG(EMULATOR_LOG_INFO, ##__VA_ARGS__); \ 121 } 122 123 #define VERBOSE_DPRINT(tag, ...) VERBOSE_PRINT(tag, __VA_ARGS__) 124 125 extern void dprintn(const char* format, ...); 126 127 extern void fdprintfnv(FILE* fp, 128 const char* level, 129 const char* format, 130 va_list args); 131 132 // Logging support. 133 134 #define dprint(fmt, ...) \ 135 if (EMULATOR_LOG_VERBOSE >= android_log_severity) { \ 136 EMULOG(EMULATOR_LOG_VERBOSE, fmt, ##__VA_ARGS__) \ 137 } 138 139 #define dinfo(fmt, ...) \ 140 if (EMULATOR_LOG_INFO >= android_log_severity) { \ 141 EMULOG(EMULATOR_LOG_INFO, fmt, ##__VA_ARGS__) \ 142 } 143 #define dwarning(fmt, ...) \ 144 if (EMULATOR_LOG_WARNING >= android_log_severity) { \ 145 EMULOG(EMULATOR_LOG_WARNING, fmt, ##__VA_ARGS__) \ 146 } 147 #define derror(fmt, ...) \ 148 if (EMULATOR_LOG_ERROR >= android_log_severity) { \ 149 EMULOG(EMULATOR_LOG_ERROR, fmt, ##__VA_ARGS__) \ 150 } 151 #define dfatal(fmt, ...) EMULOG(EMULATOR_LOG_FATAL, fmt, ##__VA_ARGS__) 152 153 /** MULTITHREADED DEBUG TRACING 154 ** 155 ** 'android_tid_function_print' is for tracing in multi-threaded situations. 156 ** It prints "emulator: " or not (depending on |use_emulator_prefix|), 157 ** the thread id, a function name (|function|), the message, and finally '\n'. 158 */ 159 extern void android_tid_function_print(bool use_emulator_prefix, 160 const char* function, 161 const char* format, 162 ...); 163 164 /** STDOUT/STDERR REDIRECTION 165 ** 166 ** allows you to shut temporarily shutdown stdout/stderr 167 ** this is useful to get rid of debug messages from ALSA and esd 168 ** on Linux. 169 **/ 170 171 extern void stdio_disable(void); 172 extern void stdio_enable(void); 173 174 ANDROID_END_HEADER 175