1*598139dcSAndroid Build Coastguard Worker /*
2*598139dcSAndroid Build Coastguard Worker * Copyright (C) 2009 The Android Open Source Project
3*598139dcSAndroid Build Coastguard Worker *
4*598139dcSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*598139dcSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*598139dcSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*598139dcSAndroid Build Coastguard Worker *
8*598139dcSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*598139dcSAndroid Build Coastguard Worker *
10*598139dcSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*598139dcSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*598139dcSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*598139dcSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*598139dcSAndroid Build Coastguard Worker * limitations under the License.
15*598139dcSAndroid Build Coastguard Worker */
16*598139dcSAndroid Build Coastguard Worker
17*598139dcSAndroid Build Coastguard Worker #pragma once
18*598139dcSAndroid Build Coastguard Worker
19*598139dcSAndroid Build Coastguard Worker /**
20*598139dcSAndroid Build Coastguard Worker * @addtogroup Logging
21*598139dcSAndroid Build Coastguard Worker * @{
22*598139dcSAndroid Build Coastguard Worker */
23*598139dcSAndroid Build Coastguard Worker
24*598139dcSAndroid Build Coastguard Worker /**
25*598139dcSAndroid Build Coastguard Worker * \file
26*598139dcSAndroid Build Coastguard Worker *
27*598139dcSAndroid Build Coastguard Worker * Support routines to send messages to the Android log buffer,
28*598139dcSAndroid Build Coastguard Worker * which can later be accessed through the `logcat` utility.
29*598139dcSAndroid Build Coastguard Worker *
30*598139dcSAndroid Build Coastguard Worker * Each log message must have
31*598139dcSAndroid Build Coastguard Worker * - a priority
32*598139dcSAndroid Build Coastguard Worker * - a log tag
33*598139dcSAndroid Build Coastguard Worker * - some text
34*598139dcSAndroid Build Coastguard Worker *
35*598139dcSAndroid Build Coastguard Worker * The tag normally corresponds to the component that emits the log message,
36*598139dcSAndroid Build Coastguard Worker * and should be reasonably small.
37*598139dcSAndroid Build Coastguard Worker *
38*598139dcSAndroid Build Coastguard Worker * Log message text may be truncated to less than an implementation-specific
39*598139dcSAndroid Build Coastguard Worker * limit (1023 bytes).
40*598139dcSAndroid Build Coastguard Worker *
41*598139dcSAndroid Build Coastguard Worker * Note that a newline character ("\n") will be appended automatically to your
42*598139dcSAndroid Build Coastguard Worker * log message, if not already there. It is not possible to send several
43*598139dcSAndroid Build Coastguard Worker * messages and have them appear on a single line in logcat.
44*598139dcSAndroid Build Coastguard Worker *
45*598139dcSAndroid Build Coastguard Worker * Please use logging in moderation:
46*598139dcSAndroid Build Coastguard Worker *
47*598139dcSAndroid Build Coastguard Worker * - Sending log messages eats CPU and slow down your application and the
48*598139dcSAndroid Build Coastguard Worker * system.
49*598139dcSAndroid Build Coastguard Worker *
50*598139dcSAndroid Build Coastguard Worker * - The circular log buffer is pretty small, so sending many messages
51*598139dcSAndroid Build Coastguard Worker * will hide other important log messages.
52*598139dcSAndroid Build Coastguard Worker *
53*598139dcSAndroid Build Coastguard Worker * - In release builds, only send log messages to account for exceptional
54*598139dcSAndroid Build Coastguard Worker * conditions.
55*598139dcSAndroid Build Coastguard Worker */
56*598139dcSAndroid Build Coastguard Worker
57*598139dcSAndroid Build Coastguard Worker #include <stdarg.h>
58*598139dcSAndroid Build Coastguard Worker #include <stdbool.h>
59*598139dcSAndroid Build Coastguard Worker #include <stddef.h>
60*598139dcSAndroid Build Coastguard Worker #include <stdint.h>
61*598139dcSAndroid Build Coastguard Worker #include <sys/cdefs.h>
62*598139dcSAndroid Build Coastguard Worker
63*598139dcSAndroid Build Coastguard Worker #if !defined(__BIONIC__) && !defined(__INTRODUCED_IN)
64*598139dcSAndroid Build Coastguard Worker #define __INTRODUCED_IN(x)
65*598139dcSAndroid Build Coastguard Worker #endif
66*598139dcSAndroid Build Coastguard Worker
67*598139dcSAndroid Build Coastguard Worker #ifdef __cplusplus
68*598139dcSAndroid Build Coastguard Worker extern "C" {
69*598139dcSAndroid Build Coastguard Worker #endif
70*598139dcSAndroid Build Coastguard Worker
71*598139dcSAndroid Build Coastguard Worker /**
72*598139dcSAndroid Build Coastguard Worker * Android log priority values, in increasing order of priority.
73*598139dcSAndroid Build Coastguard Worker */
74*598139dcSAndroid Build Coastguard Worker typedef enum android_LogPriority {
75*598139dcSAndroid Build Coastguard Worker /** For internal use only. */
76*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_UNKNOWN = 0,
77*598139dcSAndroid Build Coastguard Worker /** The default priority, for internal use only. */
78*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
79*598139dcSAndroid Build Coastguard Worker /** Verbose logging. Should typically be disabled for a release apk. */
80*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_VERBOSE,
81*598139dcSAndroid Build Coastguard Worker /** Debug logging. Should typically be disabled for a release apk. */
82*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_DEBUG,
83*598139dcSAndroid Build Coastguard Worker /** Informational logging. Should typically be disabled for a release apk. */
84*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_INFO,
85*598139dcSAndroid Build Coastguard Worker /** Warning logging. For use with recoverable failures. */
86*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_WARN,
87*598139dcSAndroid Build Coastguard Worker /** Error logging. For use with unrecoverable failures. */
88*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_ERROR,
89*598139dcSAndroid Build Coastguard Worker /** Fatal logging. For use when aborting. */
90*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_FATAL,
91*598139dcSAndroid Build Coastguard Worker /** For internal use only. */
92*598139dcSAndroid Build Coastguard Worker ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
93*598139dcSAndroid Build Coastguard Worker } android_LogPriority;
94*598139dcSAndroid Build Coastguard Worker
95*598139dcSAndroid Build Coastguard Worker /**
96*598139dcSAndroid Build Coastguard Worker * Writes the constant string `text` to the log, with priority `prio` and tag
97*598139dcSAndroid Build Coastguard Worker * `tag`.
98*598139dcSAndroid Build Coastguard Worker *
99*598139dcSAndroid Build Coastguard Worker * @return 1 if the message was written to the log, or -EPERM if it was not; see
100*598139dcSAndroid Build Coastguard Worker * __android_log_is_loggable().
101*598139dcSAndroid Build Coastguard Worker */
102*598139dcSAndroid Build Coastguard Worker int __android_log_write(int prio, const char* tag, const char* text);
103*598139dcSAndroid Build Coastguard Worker
104*598139dcSAndroid Build Coastguard Worker /**
105*598139dcSAndroid Build Coastguard Worker * Writes a formatted string to the log, with priority `prio` and tag `tag`.
106*598139dcSAndroid Build Coastguard Worker * The details of formatting are the same as for
107*598139dcSAndroid Build Coastguard Worker * [printf(3)](http://man7.org/linux/man-pages/man3/printf.3.html).
108*598139dcSAndroid Build Coastguard Worker *
109*598139dcSAndroid Build Coastguard Worker * @return 1 if the message was written to the log, or -EPERM if it was not; see
110*598139dcSAndroid Build Coastguard Worker * __android_log_is_loggable().
111*598139dcSAndroid Build Coastguard Worker */
112*598139dcSAndroid Build Coastguard Worker int __android_log_print(int prio, const char* tag, const char* fmt, ...)
113*598139dcSAndroid Build Coastguard Worker __attribute__((__format__(printf, 3, 4)));
114*598139dcSAndroid Build Coastguard Worker
115*598139dcSAndroid Build Coastguard Worker /**
116*598139dcSAndroid Build Coastguard Worker * Equivalent to __android_log_print(), but taking a `va_list`.
117*598139dcSAndroid Build Coastguard Worker * (If __android_log_print() is like printf(), this is like vprintf().)
118*598139dcSAndroid Build Coastguard Worker *
119*598139dcSAndroid Build Coastguard Worker * @return 1 if the message was written to the log, or -EPERM if it was not; see
120*598139dcSAndroid Build Coastguard Worker * __android_log_is_loggable().
121*598139dcSAndroid Build Coastguard Worker */
122*598139dcSAndroid Build Coastguard Worker int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
123*598139dcSAndroid Build Coastguard Worker __attribute__((__format__(printf, 3, 0)));
124*598139dcSAndroid Build Coastguard Worker
125*598139dcSAndroid Build Coastguard Worker /**
126*598139dcSAndroid Build Coastguard Worker * Writes an assertion failure to the log (as `ANDROID_LOG_FATAL`) and to
127*598139dcSAndroid Build Coastguard Worker * stderr, before calling
128*598139dcSAndroid Build Coastguard Worker * [abort(3)](http://man7.org/linux/man-pages/man3/abort.3.html).
129*598139dcSAndroid Build Coastguard Worker *
130*598139dcSAndroid Build Coastguard Worker * If `fmt` is non-null, `cond` is unused. If `fmt` is null, the string
131*598139dcSAndroid Build Coastguard Worker * `Assertion failed: %s` is used with `cond` as the string argument.
132*598139dcSAndroid Build Coastguard Worker * If both `fmt` and `cond` are null, a default string is provided.
133*598139dcSAndroid Build Coastguard Worker *
134*598139dcSAndroid Build Coastguard Worker * Most callers should use
135*598139dcSAndroid Build Coastguard Worker * [assert(3)](http://man7.org/linux/man-pages/man3/assert.3.html) from
136*598139dcSAndroid Build Coastguard Worker * `<assert.h>` instead, or the `__assert` and `__assert2` functions
137*598139dcSAndroid Build Coastguard Worker * provided by bionic if more control is needed. They support automatically
138*598139dcSAndroid Build Coastguard Worker * including the source filename and line number more conveniently than this
139*598139dcSAndroid Build Coastguard Worker * function.
140*598139dcSAndroid Build Coastguard Worker */
141*598139dcSAndroid Build Coastguard Worker void __android_log_assert(const char* cond, const char* tag, const char* fmt, ...)
142*598139dcSAndroid Build Coastguard Worker __attribute__((__noreturn__)) __attribute__((__format__(printf, 3, 4)));
143*598139dcSAndroid Build Coastguard Worker
144*598139dcSAndroid Build Coastguard Worker /**
145*598139dcSAndroid Build Coastguard Worker * Identifies a specific log buffer for __android_log_buf_write()
146*598139dcSAndroid Build Coastguard Worker * and __android_log_buf_print().
147*598139dcSAndroid Build Coastguard Worker */
148*598139dcSAndroid Build Coastguard Worker typedef enum log_id {
149*598139dcSAndroid Build Coastguard Worker LOG_ID_MIN = 0,
150*598139dcSAndroid Build Coastguard Worker
151*598139dcSAndroid Build Coastguard Worker /** The main log buffer. This is the only log buffer available to apps. */
152*598139dcSAndroid Build Coastguard Worker LOG_ID_MAIN = 0,
153*598139dcSAndroid Build Coastguard Worker /** The radio log buffer. */
154*598139dcSAndroid Build Coastguard Worker LOG_ID_RADIO = 1,
155*598139dcSAndroid Build Coastguard Worker /** The event log buffer. */
156*598139dcSAndroid Build Coastguard Worker LOG_ID_EVENTS = 2,
157*598139dcSAndroid Build Coastguard Worker /** The system log buffer. */
158*598139dcSAndroid Build Coastguard Worker LOG_ID_SYSTEM = 3,
159*598139dcSAndroid Build Coastguard Worker /** The crash log buffer. */
160*598139dcSAndroid Build Coastguard Worker LOG_ID_CRASH = 4,
161*598139dcSAndroid Build Coastguard Worker /** The statistics log buffer. */
162*598139dcSAndroid Build Coastguard Worker LOG_ID_STATS = 5,
163*598139dcSAndroid Build Coastguard Worker /** The security log buffer. */
164*598139dcSAndroid Build Coastguard Worker LOG_ID_SECURITY = 6,
165*598139dcSAndroid Build Coastguard Worker /** The kernel log buffer. */
166*598139dcSAndroid Build Coastguard Worker LOG_ID_KERNEL = 7,
167*598139dcSAndroid Build Coastguard Worker
168*598139dcSAndroid Build Coastguard Worker LOG_ID_MAX,
169*598139dcSAndroid Build Coastguard Worker
170*598139dcSAndroid Build Coastguard Worker /** Let the logging function choose the best log target. */
171*598139dcSAndroid Build Coastguard Worker LOG_ID_DEFAULT = 0x7FFFFFFF
172*598139dcSAndroid Build Coastguard Worker } log_id_t;
173*598139dcSAndroid Build Coastguard Worker
__android_log_id_is_valid(log_id_t id)174*598139dcSAndroid Build Coastguard Worker static inline bool __android_log_id_is_valid(log_id_t id) {
175*598139dcSAndroid Build Coastguard Worker return id >= LOG_ID_MIN && id < LOG_ID_MAX;
176*598139dcSAndroid Build Coastguard Worker }
177*598139dcSAndroid Build Coastguard Worker
178*598139dcSAndroid Build Coastguard Worker /**
179*598139dcSAndroid Build Coastguard Worker * Writes the constant string `text` to the log buffer `id`,
180*598139dcSAndroid Build Coastguard Worker * with priority `prio` and tag `tag`.
181*598139dcSAndroid Build Coastguard Worker *
182*598139dcSAndroid Build Coastguard Worker * Apps should use __android_log_write() instead.
183*598139dcSAndroid Build Coastguard Worker *
184*598139dcSAndroid Build Coastguard Worker * @return 1 if the message was written to the log, or -EPERM if it was not; see
185*598139dcSAndroid Build Coastguard Worker * __android_log_is_loggable().
186*598139dcSAndroid Build Coastguard Worker */
187*598139dcSAndroid Build Coastguard Worker int __android_log_buf_write(int bufID, int prio, const char* tag, const char* text);
188*598139dcSAndroid Build Coastguard Worker
189*598139dcSAndroid Build Coastguard Worker /**
190*598139dcSAndroid Build Coastguard Worker * Writes a formatted string to log buffer `id`,
191*598139dcSAndroid Build Coastguard Worker * with priority `prio` and tag `tag`.
192*598139dcSAndroid Build Coastguard Worker * The details of formatting are the same as for
193*598139dcSAndroid Build Coastguard Worker * [printf(3)](http://man7.org/linux/man-pages/man3/printf.3.html).
194*598139dcSAndroid Build Coastguard Worker *
195*598139dcSAndroid Build Coastguard Worker * Apps should use __android_log_print() instead.
196*598139dcSAndroid Build Coastguard Worker *
197*598139dcSAndroid Build Coastguard Worker * @return 1 if the message was written to the log, or -EPERM if it was not; see
198*598139dcSAndroid Build Coastguard Worker * __android_log_is_loggable().
199*598139dcSAndroid Build Coastguard Worker */
200*598139dcSAndroid Build Coastguard Worker int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fmt, ...)
201*598139dcSAndroid Build Coastguard Worker __attribute__((__format__(printf, 4, 5)));
202*598139dcSAndroid Build Coastguard Worker
203*598139dcSAndroid Build Coastguard Worker /**
204*598139dcSAndroid Build Coastguard Worker * Logger data struct used for writing log messages to liblog via __android_log_write_logger_data()
205*598139dcSAndroid Build Coastguard Worker * and sending log messages to user defined loggers specified in __android_log_set_logger().
206*598139dcSAndroid Build Coastguard Worker */
207*598139dcSAndroid Build Coastguard Worker struct __android_log_message {
208*598139dcSAndroid Build Coastguard Worker /** Must be set to `sizeof(__android_log_message)` and is used for versioning. */
209*598139dcSAndroid Build Coastguard Worker size_t struct_size;
210*598139dcSAndroid Build Coastguard Worker
211*598139dcSAndroid Build Coastguard Worker /** {@link log_id_t} values. */
212*598139dcSAndroid Build Coastguard Worker int32_t buffer_id;
213*598139dcSAndroid Build Coastguard Worker
214*598139dcSAndroid Build Coastguard Worker /** {@link android_LogPriority} values. */
215*598139dcSAndroid Build Coastguard Worker int32_t priority;
216*598139dcSAndroid Build Coastguard Worker
217*598139dcSAndroid Build Coastguard Worker /** The tag for the log message. */
218*598139dcSAndroid Build Coastguard Worker const char* tag;
219*598139dcSAndroid Build Coastguard Worker
220*598139dcSAndroid Build Coastguard Worker /** Optional file name, may be set to nullptr. */
221*598139dcSAndroid Build Coastguard Worker const char* file;
222*598139dcSAndroid Build Coastguard Worker
223*598139dcSAndroid Build Coastguard Worker /** Optional line number, ignore if file is nullptr. */
224*598139dcSAndroid Build Coastguard Worker uint32_t line;
225*598139dcSAndroid Build Coastguard Worker
226*598139dcSAndroid Build Coastguard Worker /** The log message itself. */
227*598139dcSAndroid Build Coastguard Worker const char* message;
228*598139dcSAndroid Build Coastguard Worker };
229*598139dcSAndroid Build Coastguard Worker
230*598139dcSAndroid Build Coastguard Worker /**
231*598139dcSAndroid Build Coastguard Worker * Prototype for the 'logger' function that is called for every log message.
232*598139dcSAndroid Build Coastguard Worker */
233*598139dcSAndroid Build Coastguard Worker typedef void (*__android_logger_function)(const struct __android_log_message* log_message);
234*598139dcSAndroid Build Coastguard Worker /**
235*598139dcSAndroid Build Coastguard Worker * Prototype for the 'abort' function that is called when liblog will abort due to
236*598139dcSAndroid Build Coastguard Worker * __android_log_assert() failures.
237*598139dcSAndroid Build Coastguard Worker */
238*598139dcSAndroid Build Coastguard Worker typedef void (*__android_aborter_function)(const char* abort_message);
239*598139dcSAndroid Build Coastguard Worker
240*598139dcSAndroid Build Coastguard Worker /**
241*598139dcSAndroid Build Coastguard Worker * Writes the log message specified by log_message. log_message includes additional file name and
242*598139dcSAndroid Build Coastguard Worker * line number information that a logger may use. log_message is versioned for backwards
243*598139dcSAndroid Build Coastguard Worker * compatibility.
244*598139dcSAndroid Build Coastguard Worker * This assumes that loggability has already been checked through __android_log_is_loggable().
245*598139dcSAndroid Build Coastguard Worker * Higher level logging libraries, such as libbase, first check loggability, then format their
246*598139dcSAndroid Build Coastguard Worker * buffers, then pass the message to liblog via this function, and therefore we do not want to
247*598139dcSAndroid Build Coastguard Worker * duplicate the loggability check here.
248*598139dcSAndroid Build Coastguard Worker *
249*598139dcSAndroid Build Coastguard Worker * @param log_message the log message itself, see {@link __android_log_message}.
250*598139dcSAndroid Build Coastguard Worker *
251*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
252*598139dcSAndroid Build Coastguard Worker */
253*598139dcSAndroid Build Coastguard Worker void __android_log_write_log_message(struct __android_log_message* log_message) __INTRODUCED_IN(30);
254*598139dcSAndroid Build Coastguard Worker
255*598139dcSAndroid Build Coastguard Worker /**
256*598139dcSAndroid Build Coastguard Worker * Sets a user defined logger function. All log messages sent to liblog will be set to the
257*598139dcSAndroid Build Coastguard Worker * function pointer specified by logger for processing. It is not expected that log messages are
258*598139dcSAndroid Build Coastguard Worker * already terminated with a new line. This function should add new lines if required for line
259*598139dcSAndroid Build Coastguard Worker * separation.
260*598139dcSAndroid Build Coastguard Worker *
261*598139dcSAndroid Build Coastguard Worker * @param logger the new function that will handle log messages.
262*598139dcSAndroid Build Coastguard Worker *
263*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
264*598139dcSAndroid Build Coastguard Worker */
265*598139dcSAndroid Build Coastguard Worker void __android_log_set_logger(__android_logger_function logger) __INTRODUCED_IN(30);
266*598139dcSAndroid Build Coastguard Worker
267*598139dcSAndroid Build Coastguard Worker /**
268*598139dcSAndroid Build Coastguard Worker * Writes the log message to logd. This is an {@link __android_logger_function} and can be provided to
269*598139dcSAndroid Build Coastguard Worker * __android_log_set_logger(). It is the default logger when running liblog on a device.
270*598139dcSAndroid Build Coastguard Worker *
271*598139dcSAndroid Build Coastguard Worker * @param log_message the log message to write, see {@link __android_log_message}.
272*598139dcSAndroid Build Coastguard Worker *
273*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
274*598139dcSAndroid Build Coastguard Worker */
275*598139dcSAndroid Build Coastguard Worker void __android_log_logd_logger(const struct __android_log_message* log_message) __INTRODUCED_IN(30);
276*598139dcSAndroid Build Coastguard Worker
277*598139dcSAndroid Build Coastguard Worker /**
278*598139dcSAndroid Build Coastguard Worker * Writes the log message to stderr. This is an {@link __android_logger_function} and can be provided to
279*598139dcSAndroid Build Coastguard Worker * __android_log_set_logger(). It is the default logger when running liblog on host.
280*598139dcSAndroid Build Coastguard Worker *
281*598139dcSAndroid Build Coastguard Worker * @param log_message the log message to write, see {@link __android_log_message}.
282*598139dcSAndroid Build Coastguard Worker *
283*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
284*598139dcSAndroid Build Coastguard Worker */
285*598139dcSAndroid Build Coastguard Worker void __android_log_stderr_logger(const struct __android_log_message* log_message)
286*598139dcSAndroid Build Coastguard Worker __INTRODUCED_IN(30);
287*598139dcSAndroid Build Coastguard Worker
288*598139dcSAndroid Build Coastguard Worker /**
289*598139dcSAndroid Build Coastguard Worker * Sets a user defined aborter function that is called for __android_log_assert() failures. This
290*598139dcSAndroid Build Coastguard Worker * user defined aborter function is highly recommended to abort and be noreturn, but is not strictly
291*598139dcSAndroid Build Coastguard Worker * required to.
292*598139dcSAndroid Build Coastguard Worker *
293*598139dcSAndroid Build Coastguard Worker * @param aborter the new aborter function, see {@link __android_aborter_function}.
294*598139dcSAndroid Build Coastguard Worker *
295*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
296*598139dcSAndroid Build Coastguard Worker */
297*598139dcSAndroid Build Coastguard Worker void __android_log_set_aborter(__android_aborter_function aborter) __INTRODUCED_IN(30);
298*598139dcSAndroid Build Coastguard Worker
299*598139dcSAndroid Build Coastguard Worker /**
300*598139dcSAndroid Build Coastguard Worker * Calls the stored aborter function. This allows for other logging libraries to use the same
301*598139dcSAndroid Build Coastguard Worker * aborter function by calling this function in liblog.
302*598139dcSAndroid Build Coastguard Worker *
303*598139dcSAndroid Build Coastguard Worker * @param abort_message an additional message supplied when aborting, for example this is used to
304*598139dcSAndroid Build Coastguard Worker * call android_set_abort_message() in __android_log_default_aborter().
305*598139dcSAndroid Build Coastguard Worker *
306*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
307*598139dcSAndroid Build Coastguard Worker */
308*598139dcSAndroid Build Coastguard Worker void __android_log_call_aborter(const char* abort_message) __INTRODUCED_IN(30);
309*598139dcSAndroid Build Coastguard Worker
310*598139dcSAndroid Build Coastguard Worker /**
311*598139dcSAndroid Build Coastguard Worker * Sets android_set_abort_message() on device then aborts(). This is the default aborter.
312*598139dcSAndroid Build Coastguard Worker *
313*598139dcSAndroid Build Coastguard Worker * @param abort_message an additional message supplied when aborting. This functions calls
314*598139dcSAndroid Build Coastguard Worker * android_set_abort_message() with its contents.
315*598139dcSAndroid Build Coastguard Worker *
316*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
317*598139dcSAndroid Build Coastguard Worker */
318*598139dcSAndroid Build Coastguard Worker void __android_log_default_aborter(const char* abort_message) __attribute__((noreturn))
319*598139dcSAndroid Build Coastguard Worker __INTRODUCED_IN(30);
320*598139dcSAndroid Build Coastguard Worker
321*598139dcSAndroid Build Coastguard Worker /**
322*598139dcSAndroid Build Coastguard Worker * Use the per-tag properties "log.tag.<tagname>" along with the minimum priority from
323*598139dcSAndroid Build Coastguard Worker * __android_log_set_minimum_priority() to determine if a log message with a given prio and tag will
324*598139dcSAndroid Build Coastguard Worker * be printed. A non-zero result indicates yes, zero indicates false.
325*598139dcSAndroid Build Coastguard Worker *
326*598139dcSAndroid Build Coastguard Worker * If both a priority for a tag and a minimum priority are set by
327*598139dcSAndroid Build Coastguard Worker * __android_log_set_minimum_priority(), then the lowest of the two values are to determine the
328*598139dcSAndroid Build Coastguard Worker * minimum priority needed to log. If only one is set, then that value is used to determine the
329*598139dcSAndroid Build Coastguard Worker * minimum priority needed. If none are set, then default_priority is used.
330*598139dcSAndroid Build Coastguard Worker *
331*598139dcSAndroid Build Coastguard Worker * @param prio the priority to test, takes {@link android_LogPriority} values.
332*598139dcSAndroid Build Coastguard Worker * @param tag the tag to test.
333*598139dcSAndroid Build Coastguard Worker * @param default_prio the default priority to use if no properties or minimum priority are set.
334*598139dcSAndroid Build Coastguard Worker * @return an integer where 1 indicates that the message is loggable and 0 indicates that it is not.
335*598139dcSAndroid Build Coastguard Worker *
336*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
337*598139dcSAndroid Build Coastguard Worker */
338*598139dcSAndroid Build Coastguard Worker int __android_log_is_loggable(int prio, const char* tag, int default_prio) __INTRODUCED_IN(30);
339*598139dcSAndroid Build Coastguard Worker
340*598139dcSAndroid Build Coastguard Worker /**
341*598139dcSAndroid Build Coastguard Worker * Use the per-tag properties "log.tag.<tagname>" along with the minimum priority from
342*598139dcSAndroid Build Coastguard Worker * __android_log_set_minimum_priority() to determine if a log message with a given prio and tag will
343*598139dcSAndroid Build Coastguard Worker * be printed. A non-zero result indicates yes, zero indicates false.
344*598139dcSAndroid Build Coastguard Worker *
345*598139dcSAndroid Build Coastguard Worker * If both a priority for a tag and a minimum priority are set by
346*598139dcSAndroid Build Coastguard Worker * __android_log_set_minimum_priority(), then the lowest of the two values are to determine the
347*598139dcSAndroid Build Coastguard Worker * minimum priority needed to log. If only one is set, then that value is used to determine the
348*598139dcSAndroid Build Coastguard Worker * minimum priority needed. If none are set, then default_priority is used.
349*598139dcSAndroid Build Coastguard Worker *
350*598139dcSAndroid Build Coastguard Worker * @param prio the priority to test, takes {@link android_LogPriority} values.
351*598139dcSAndroid Build Coastguard Worker * @param tag the tag to test.
352*598139dcSAndroid Build Coastguard Worker * @param len the length of the tag.
353*598139dcSAndroid Build Coastguard Worker * @param default_prio the default priority to use if no properties or minimum priority are set.
354*598139dcSAndroid Build Coastguard Worker * @return an integer where 1 indicates that the message is loggable and 0 indicates that it is not.
355*598139dcSAndroid Build Coastguard Worker *
356*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
357*598139dcSAndroid Build Coastguard Worker */
358*598139dcSAndroid Build Coastguard Worker int __android_log_is_loggable_len(int prio, const char* tag, size_t len, int default_prio)
359*598139dcSAndroid Build Coastguard Worker __INTRODUCED_IN(30);
360*598139dcSAndroid Build Coastguard Worker
361*598139dcSAndroid Build Coastguard Worker /**
362*598139dcSAndroid Build Coastguard Worker * Sets the minimum priority that will be logged for this process.
363*598139dcSAndroid Build Coastguard Worker *
364*598139dcSAndroid Build Coastguard Worker * @param priority the new minimum priority to set, takes {@link android_LogPriority} values.
365*598139dcSAndroid Build Coastguard Worker * @return the previous set minimum priority, or `ANDROID_LOG_DEFAULT` if none was set.
366*598139dcSAndroid Build Coastguard Worker *
367*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
368*598139dcSAndroid Build Coastguard Worker */
369*598139dcSAndroid Build Coastguard Worker int32_t __android_log_set_minimum_priority(int32_t priority) __INTRODUCED_IN(30);
370*598139dcSAndroid Build Coastguard Worker
371*598139dcSAndroid Build Coastguard Worker /**
372*598139dcSAndroid Build Coastguard Worker * Gets the minimum priority that will be logged for this process.
373*598139dcSAndroid Build Coastguard Worker *
374*598139dcSAndroid Build Coastguard Worker * @return the current minimum priority, or `ANDROID_LOG_DEFAULT` if none is set.
375*598139dcSAndroid Build Coastguard Worker *
376*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
377*598139dcSAndroid Build Coastguard Worker */
378*598139dcSAndroid Build Coastguard Worker int32_t __android_log_get_minimum_priority(void) __INTRODUCED_IN(30);
379*598139dcSAndroid Build Coastguard Worker
380*598139dcSAndroid Build Coastguard Worker /**
381*598139dcSAndroid Build Coastguard Worker * Sets the default tag if no tag is provided when writing a log message. Defaults to
382*598139dcSAndroid Build Coastguard Worker * getprogname(). This truncates tag to the maximum log message size, though appropriate tags
383*598139dcSAndroid Build Coastguard Worker * should be much smaller.
384*598139dcSAndroid Build Coastguard Worker *
385*598139dcSAndroid Build Coastguard Worker * @param tag the new log tag.
386*598139dcSAndroid Build Coastguard Worker *
387*598139dcSAndroid Build Coastguard Worker * Available since API level 30.
388*598139dcSAndroid Build Coastguard Worker */
389*598139dcSAndroid Build Coastguard Worker void __android_log_set_default_tag(const char* tag) __INTRODUCED_IN(30);
390*598139dcSAndroid Build Coastguard Worker
391*598139dcSAndroid Build Coastguard Worker #ifdef __cplusplus
392*598139dcSAndroid Build Coastguard Worker }
393*598139dcSAndroid Build Coastguard Worker #endif
394*598139dcSAndroid Build Coastguard Worker
395*598139dcSAndroid Build Coastguard Worker /** @} */
396