Path: blob/21.2-virgl/include/android_stub/log/log_system.h
4547 views
/*1* Copyright (C) 2005-2017 The Android Open Source Project2*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 at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* 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 and13* limitations under the License.14*/1516#pragma once1718#include <android/log.h>1920/*21* Normally we strip the effects of ALOGV (VERBOSE messages),22* LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the23* release builds be defining NDEBUG. You can modify this (for24* example with "#define LOG_NDEBUG 0" at the top of your source25* file) to change that behavior.26*/2728#ifndef LOG_NDEBUG29#ifdef NDEBUG30#define LOG_NDEBUG 131#else32#define LOG_NDEBUG 033#endif34#endif3536#ifndef __predict_false37#define __predict_false(exp) __builtin_expect((exp) != 0, 0)38#endif3940/*41* Simplified macro to send a verbose system log message using current LOG_TAG.42*/43#ifndef SLOGV44#define __SLOGV(...) \45((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, \46__VA_ARGS__))47#if LOG_NDEBUG48#define SLOGV(...) \49do { \50if (0) { \51__SLOGV(__VA_ARGS__); \52} \53} while (0)54#else55#define SLOGV(...) __SLOGV(__VA_ARGS__)56#endif57#endif5859#ifndef SLOGV_IF60#if LOG_NDEBUG61#define SLOGV_IF(cond, ...) ((void)0)62#else63#define SLOGV_IF(cond, ...) \64((__predict_false(cond)) \65? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, \66LOG_TAG, __VA_ARGS__)) \67: (void)0)68#endif69#endif7071/*72* Simplified macro to send a debug system log message using current LOG_TAG.73*/74#ifndef SLOGD75#define SLOGD(...) \76((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, \77__VA_ARGS__))78#endif7980#ifndef SLOGD_IF81#define SLOGD_IF(cond, ...) \82((__predict_false(cond)) \83? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, \84LOG_TAG, __VA_ARGS__)) \85: (void)0)86#endif8788/*89* Simplified macro to send an info system log message using current LOG_TAG.90*/91#ifndef SLOGI92#define SLOGI(...) \93((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, \94__VA_ARGS__))95#endif9697#ifndef SLOGI_IF98#define SLOGI_IF(cond, ...) \99((__predict_false(cond)) \100? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, \101LOG_TAG, __VA_ARGS__)) \102: (void)0)103#endif104105/*106* Simplified macro to send a warning system log message using current LOG_TAG.107*/108#ifndef SLOGW109#define SLOGW(...) \110((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, \111__VA_ARGS__))112#endif113114#ifndef SLOGW_IF115#define SLOGW_IF(cond, ...) \116((__predict_false(cond)) \117? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, \118LOG_TAG, __VA_ARGS__)) \119: (void)0)120#endif121122/*123* Simplified macro to send an error system log message using current LOG_TAG.124*/125#ifndef SLOGE126#define SLOGE(...) \127((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, \128__VA_ARGS__))129#endif130131#ifndef SLOGE_IF132#define SLOGE_IF(cond, ...) \133((__predict_false(cond)) \134? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, \135LOG_TAG, __VA_ARGS__)) \136: (void)0)137#endif138139140