1 // Copyright (C) 2021 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 #pragma once 15 16 #include <stdint.h> 17 18 #ifndef LOGGING_API 19 #ifdef _MSC_VER 20 #ifdef LOGGING_API_SHARED 21 #define LOGGING_API __declspec(dllexport) 22 #else 23 #define LOGGING_API __declspec(dllimport) 24 #endif 25 #else 26 #define LOGGING_API 27 #endif 28 #endif 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #define LOG_SEVERITY 35 // Defines the available log severities. 36 typedef enum LogSeverity { 37 EMULATOR_LOG_VERBOSE = -2, 38 EMULATOR_LOG_DEBUG = -1, 39 EMULATOR_LOG_INFO = 0, 40 EMULATOR_LOG_WARNING = 1, 41 EMULATOR_LOG_ERROR = 2, 42 EMULATOR_LOG_FATAL = 3, 43 EMULATOR_LOG_NUM_SEVERITIES, 44 45 // DFATAL will be ERROR in release builds, and FATAL in debug ones. 46 #ifdef NDEBUG 47 EMULATOR_LOG_DFATAL = EMULATOR_LOG_ERROR, 48 #else 49 EMULATOR_LOG_DFATAL = EMULATOR_LOG_FATAL, 50 #endif 51 } LogSeverity; 52 53 // Returns the minimal log level. 54 LOGGING_API LogSeverity getMinLogLevel(); 55 LOGGING_API void setMinLogLevel(LogSeverity level); 56 57 58 typedef enum { 59 kLogDefaultOptions = 0, 60 kLogEnableDuplicateFilter = 1, 61 kLogEnableTime = 1 << 2, 62 kLogEnableVerbose = 1 << 3, 63 } LoggingFlags; 64 65 // Enable/disable verbose logs from the base/* family. 66 LOGGING_API void base_enable_verbose_logs(); 67 LOGGING_API void base_disable_verbose_logs(); 68 69 LOGGING_API void verbose_enable(uint64_t tag); 70 LOGGING_API void verbose_disable(uint64_t tag); 71 LOGGING_API bool verbose_check(uint64_t tag); 72 LOGGING_API bool verbose_check_any(); 73 LOGGING_API void set_verbosity_mask(uint64_t mask); 74 LOGGING_API uint64_t get_verbosity_mask(); 75 76 // Configure the logging framework. 77 LOGGING_API void base_configure_logs(LoggingFlags flags); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83