1ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/* 2ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Copyright (C) 2009 The Android Open Source Project 3ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 4ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Licensed under the Apache License, Version 2.0 (the "License"); 5ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * you may not use this file except in compliance with the License. 6ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * You may obtain a copy of the License at 7ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 8ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * http://www.apache.org/licenses/LICENSE-2.0 9ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 10ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Unless required by applicable law or agreed to in writing, software 11ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * distributed under the License is distributed on an "AS IS" BASIS, 12ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * See the License for the specific language governing permissions and 14ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * limitations under the License. 15ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 16ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 17ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#ifndef _ANDROID_LOG_H 18ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#define _ANDROID_LOG_H 19ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 20ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/****************************************************************** 21ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 22ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * IMPORTANT NOTICE: 23ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 24ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * This file is part of Android's set of stable system headers 25ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * exposed by the Android NDK (Native Development Kit) since 26ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * platform release 1.5 27ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 28ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Third-party source AND binary code relies on the definitions 29ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. 30ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 31ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) 32ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS 33ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY 34ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES 35ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 36ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 37ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/* 38ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Support routines to send messages to the Android in-kernel log buffer, 39ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * which can later be accessed through the 'logcat' utility. 40ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 41ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Each log message must have 42ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - a priority 43ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - a log tag 44ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - some text 45ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 46ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * The tag normally corresponds to the component that emits the log message, 47ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * and should be reasonably small. 48ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 49ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Log message text may be truncated to less than an implementation-specific 50ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * limit (e.g. 1023 characters max). 51ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 52ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Note that a newline character ("\n") will be appended automatically to your 53ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * log message, if not already there. It is not possible to send several messages 54ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * and have them appear on a single line in logcat. 55ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 56ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * PLEASE USE LOGS WITH MODERATION: 57ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 58ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - Sending log messages eats CPU and slow down your application and the 59ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * system. 60ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 61ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - The circular log buffer is pretty small (<64KB), sending many messages 62ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * might push off other important log messages from the rest of the system. 63ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 64ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * - In release builds, only send log messages to account for exceptional 65ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * conditions. 66ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * 67ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * NOTE: These functions MUST be implemented by /system/lib/liblog.so 68ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 69ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 70ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#include <stdarg.h> 71ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 72ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#ifdef __cplusplus 73ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turnerextern "C" { 74ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#endif 75ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 76ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/* 77ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Android log priority values, in ascending priority order. 78ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 79ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turnertypedef enum android_LogPriority { 80ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_UNKNOWN = 0, 81ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ 82ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_VERBOSE, 83ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_DEBUG, 84ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_INFO, 85ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_WARN, 86ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_ERROR, 87ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_FATAL, 88ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ 89ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner} android_LogPriority; 90ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 91ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/* 92ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Send a simple string to the log. 93ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 94ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turnerint __android_log_write(int prio, const char *tag, const char *text); 95ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 96ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/* 97ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * Send a formatted string to the log, used like printf(fmt,...) 98ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 99ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turnerint __android_log_print(int prio, const char *tag, const char *fmt, ...) 100ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#if defined(__GNUC__) 1010cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen#ifdef __USE_MINGW_ANSI_STDIO 102ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh#if __USE_MINGW_ANSI_STDIO 103ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh __attribute__ ((format(gnu_printf, 3, 4))) 104ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh#else 105ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner __attribute__ ((format(printf, 3, 4))) 106ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#endif 1070cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen#else 1080cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen __attribute__ ((format(printf, 3, 4))) 1090cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen#endif 110ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh#endif 111ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ; 112ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 113ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/* 114ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * A variant of __android_log_print() that takes a va_list to list 115ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner * additional parameters. 116ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 117ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turnerint __android_log_vprint(int prio, const char *tag, 118ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner const char *fmt, va_list ap); 119ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 120ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner/* 121da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes * Log an assertion failure and abort the process to have a chance 122da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes * to inspect it if a debugger is attached. This uses the FATAL priority. 123ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner */ 124ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turnervoid __android_log_assert(const char *cond, const char *tag, 125da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes const char *fmt, ...) 126ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#if defined(__GNUC__) 127ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner __attribute__ ((noreturn)) 1280cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen#ifdef __USE_MINGW_ANSI_STDIO 129ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh#if __USE_MINGW_ANSI_STDIO 130ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh __attribute__ ((format(gnu_printf, 3, 4))) 131ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh#else 132ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner __attribute__ ((format(printf, 3, 4))) 133ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#endif 1340cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen#else 1350cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen __attribute__ ((format(printf, 3, 4))) 1360cddcc67ccee57b4f06d0b1c4fef70ef9d16f0a3Dan Willemsen#endif 137ad832859a7ccd7ba44b6f97e0933ab0b413d62b6Andrew Hsieh#endif 138ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner ; 139ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 140ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#ifdef __cplusplus 141ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner} 142ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#endif 143ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner 144ebefc48e61a7d5cf2a3228e6c8729feeeb42d1b4David 'Digit' Turner#endif /* _ANDROID_LOG_H */ 145