1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** Licensed under the Apache License, Version 2.0 (the "License"); 4 ** you may not use this file except in compliance with the License. 5 ** You may obtain a copy of the License at 6 ** 7 ** http://www.apache.org/licenses/LICENSE-2.0 8 ** 9 ** Unless required by applicable law or agreed to in writing, software 10 ** distributed under the License is distributed on an "AS IS" BASIS, 11 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 ** See the License for the specific language governing permissions and 13 ** limitations under the License. 14 */ 15 16 #pragma once 17 18 #include <stdarg.h> 19 #include <stdbool.h> 20 #include <stdint.h> 21 #include <stdio.h> 22 #include "aemu/base/logging/LogSeverity.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef enum { 29 kLogDefaultOptions = 0, 30 kLogEnableDuplicateFilter = 1, 31 kLogEnableTime = 1 << 2, 32 kLogEnableVerbose = 1 << 3, 33 } LoggingFlags; 34 35 36 // Enable/disable verbose logs from the base/* family. 37 extern void base_enable_verbose_logs(); 38 extern void base_disable_verbose_logs(); 39 40 // Configure the logging framework. 41 extern void base_configure_logs(LoggingFlags flags); 42 extern void __emu_log_print(LogSeverity prio, 43 const char* file, 44 int line, 45 const char* fmt, 46 ...); 47 48 #ifndef EMULOG 49 #define EMULOG(priority, fmt, ...) \ 50 __emu_log_print(priority, __FILE__, __LINE__, fmt, ##__VA_ARGS__); 51 #endif 52 53 // Logging support. 54 #define dprint(fmt, ...) \ 55 if (EMULATOR_LOG_DEBUG >= android_log_severity) { \ 56 EMULOG(EMULATOR_LOG_DEBUG, fmt, ##__VA_ARGS__) \ 57 } 58 59 #define dinfo(fmt, ...) \ 60 if (EMULATOR_LOG_INFO >= android_log_severity) { \ 61 EMULOG(EMULATOR_LOG_INFO, fmt, ##__VA_ARGS__) \ 62 } 63 #define dwarning(fmt, ...) \ 64 if (EMULATOR_LOG_WARNING >= android_log_severity) { \ 65 EMULOG(EMULATOR_LOG_WARNING, fmt, ##__VA_ARGS__) \ 66 } 67 #define derror(fmt, ...) \ 68 if (EMULATOR_LOG_ERROR >= android_log_severity) { \ 69 EMULOG(EMULATOR_LOG_ERROR, fmt, ##__VA_ARGS__) \ 70 } 71 #define dfatal(fmt, ...) EMULOG(EMULATOR_LOG_FATAL, fmt, ##__VA_ARGS__) 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77