Path: blob/21.2-virgl/include/android_stub/log/log.h
4547 views
/*1* Copyright (C) 2005-2014 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/* Too many in the ecosystem assume these are included */19#if !defined(_WIN32)20#include <pthread.h>21#endif22#include <stdint.h> /* uint16_t, int32_t */23#include <stdio.h>24#include <time.h>25#include <unistd.h>2627#include <android/log.h>28#include <log/log_id.h>29#include <log/log_main.h>30#include <log/log_radio.h>31#include <log/log_safetynet.h>32#include <log/log_system.h>33#include <log/log_time.h>3435#ifdef __cplusplus36extern "C" {37#endif3839/*40* LOG_TAG is the local tag used for the following simplified41* logging macros. You can change this preprocessor definition42* before using the other macros to change the tag.43*/4445#ifndef LOG_TAG46#define LOG_TAG NULL47#endif4849/*50* Normally we strip the effects of ALOGV (VERBOSE messages),51* LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the52* release builds be defining NDEBUG. You can modify this (for53* example with "#define LOG_NDEBUG 0" at the top of your source54* file) to change that behavior.55*/5657#ifndef LOG_NDEBUG58#ifdef NDEBUG59#define LOG_NDEBUG 160#else61#define LOG_NDEBUG 062#endif63#endif6465/*66* The maximum size of the log entry payload that can be67* written to the logger. An attempt to write more than68* this amount will result in a truncated log entry.69*/70#define LOGGER_ENTRY_MAX_PAYLOAD 40687172/*73* Event logging.74*/7576/*77* The following should not be used directly.78*/7980int __android_log_bwrite(int32_t tag, const void* payload, size_t len);81int __android_log_btwrite(int32_t tag, char type, const void* payload,82size_t len);83int __android_log_bswrite(int32_t tag, const char* payload);8485int __android_log_stats_bwrite(int32_t tag, const void* payload, size_t len);8687#define android_bWriteLog(tag, payload, len) \88__android_log_bwrite(tag, payload, len)89#define android_btWriteLog(tag, type, payload, len) \90__android_log_btwrite(tag, type, payload, len)9192/*93* Event log entry types.94*/95typedef enum {96/* Special markers for android_log_list_element type */97EVENT_TYPE_LIST_STOP = '\n', /* declare end of list */98EVENT_TYPE_UNKNOWN = '?', /* protocol error */99100/* must match with declaration in java/android/android/util/EventLog.java */101EVENT_TYPE_INT = 0, /* int32_t */102EVENT_TYPE_LONG = 1, /* int64_t */103EVENT_TYPE_STRING = 2,104EVENT_TYPE_LIST = 3,105EVENT_TYPE_FLOAT = 4,106} AndroidEventLogType;107108#ifndef LOG_EVENT_INT109#define LOG_EVENT_INT(_tag, _value) \110{ \111int intBuf = _value; \112(void)android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)); \113}114#endif115#ifndef LOG_EVENT_LONG116#define LOG_EVENT_LONG(_tag, _value) \117{ \118long long longBuf = _value; \119(void)android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, sizeof(longBuf)); \120}121#endif122#ifndef LOG_EVENT_FLOAT123#define LOG_EVENT_FLOAT(_tag, _value) \124{ \125float floatBuf = _value; \126(void)android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \127sizeof(floatBuf)); \128}129#endif130#ifndef LOG_EVENT_STRING131#define LOG_EVENT_STRING(_tag, _value) \132(void)__android_log_bswrite(_tag, _value);133#endif134135/* --------------------------------------------------------------------- */136137/*138* Release any logger resources (a new log write will immediately re-acquire)139*140* This is specifically meant to be used by Zygote to close open file descriptors after fork()141* and before specialization. O_CLOEXEC is used on file descriptors, so they will be closed upon142* exec() in normal use cases.143*144* Note that this is not safe to call from a multi-threaded program.145*/146void __android_log_close(void);147148#ifdef __cplusplus149}150#endif151152153