blob: 90ea76ef02e9ff8ddb729f78fa1d6623333541c6 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
Elliott Hughesa382a792014-06-09 17:16:19 -070028
Elliott Hughes462e90c2018-08-21 16:10:48 -070029#pragma once
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080030
31#include <stdio.h>
32#include <sys/cdefs.h>
33#include <stdarg.h>
34
35__BEGIN_DECLS
36
Elliott Hughes462e90c2018-08-21 16:10:48 -070037/** Corresponds to the Android ERROR log priority. */
38#define LOG_EMERG 0
39/** Corresponds to the Android ERROR log priority. */
40#define LOG_ALERT 1
41/** Corresponds to the Android ERROR log priority. */
42#define LOG_CRIT 2
43/** Corresponds to the Android ERROR log priority. */
44#define LOG_ERR 3
45/** Corresponds to the Android WARN log priority. */
46#define LOG_WARNING 4
47/** Corresponds to the Android INFO log priority. */
48#define LOG_NOTICE 5
49/** Corresponds to the Android INFO log priority. */
50#define LOG_INFO 6
51/** Corresponds to the Android DEBUG log priority. */
52#define LOG_DEBUG 7
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080053
Elliott Hughesafe63602014-07-23 11:38:38 -070054#define LOG_PRIMASK 7
55#define LOG_PRI(x) ((x) & LOG_PRIMASK)
Mark Salyzync4a586d2015-03-12 13:21:35 -070056#define LOG_MAKEPRI(fac, pri) ((fac) | (pri))
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080057
Elliott Hughes462e90c2018-08-21 16:10:48 -070058/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070059#define LOG_KERN (0<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070060/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070061#define LOG_USER (1<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070062/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070063#define LOG_MAIL (2<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070064/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070065#define LOG_DAEMON (3<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070066/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070067#define LOG_AUTH (4<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070068/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070069#define LOG_SYSLOG (5<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070070/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070071#define LOG_LPR (6<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070072/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070073#define LOG_NEWS (7<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070074/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070075#define LOG_UUCP (8<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070076/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070077#define LOG_CRON (9<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070078/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070079#define LOG_AUTHPRIV (10<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070080/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070081#define LOG_FTP (11<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070082/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070083#define LOG_LOCAL0 (16<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070084/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070085#define LOG_LOCAL1 (17<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070086/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070087#define LOG_LOCAL2 (18<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070088/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070089#define LOG_LOCAL3 (19<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070090/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070091#define LOG_LOCAL4 (20<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070092/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070093#define LOG_LOCAL5 (21<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070094/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070095#define LOG_LOCAL6 (22<<3)
Elliott Hughes462e90c2018-08-21 16:10:48 -070096/** Currently ignored on Android. */
Elliott Hughesf5172882017-08-03 14:44:13 -070097#define LOG_LOCAL7 (23<<3)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080098
Elliott Hughesf5172882017-08-03 14:44:13 -070099#define LOG_NFACILITIES 24
100#define LOG_FACMASK 0x3f8
Elliott Hughesafe63602014-07-23 11:38:38 -0700101#define LOG_FAC(x) (((x) >> 3) & (LOG_FACMASK >> 3))
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800102
Elliott Hughes462e90c2018-08-21 16:10:48 -0700103/**
104 * Converts a log priority into a mask enabling that single priority,
105 * for use with setlogmask().
106 */
Elliott Hughesa382a792014-06-09 17:16:19 -0700107#define LOG_MASK(pri) (1 << (pri))
Elliott Hughes462e90c2018-08-21 16:10:48 -0700108
109/**
110 * Converts a log priority into a mask enabling that priority and all lower
111 * priorities, for use with setlogmask().
112 */
Elliott Hughesa382a792014-06-09 17:16:19 -0700113#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800114
Elliott Hughes213d9432023-03-01 22:56:13 +0000115/** openlog() option ignored on Android. */
Elliott Hughes3ad8ecb2014-07-21 16:35:24 -0700116#define LOG_PID 0x01
Elliott Hughes213d9432023-03-01 22:56:13 +0000117/** openlog() option ignored on Android. */
Elliott Hughes3ad8ecb2014-07-21 16:35:24 -0700118#define LOG_CONS 0x02
Elliott Hughes213d9432023-03-01 22:56:13 +0000119/** openlog() option ignored on Android. */
Elliott Hughes3ad8ecb2014-07-21 16:35:24 -0700120#define LOG_ODELAY 0x04
Elliott Hughes213d9432023-03-01 22:56:13 +0000121/** openlog() option ignored on Android. */
Elliott Hughes3ad8ecb2014-07-21 16:35:24 -0700122#define LOG_NDELAY 0x08
Elliott Hughes213d9432023-03-01 22:56:13 +0000123/** openlog() option ignored on Android. */
Elliott Hughes3ad8ecb2014-07-21 16:35:24 -0700124#define LOG_NOWAIT 0x10
Elliott Hughes213d9432023-03-01 22:56:13 +0000125/**
126 * openlog() option to log to stderr as well as the system log.
127 *
128 * Available since API level 34 (ignored before then).
129 */
Elliott Hughes3ad8ecb2014-07-21 16:35:24 -0700130#define LOG_PERROR 0x20
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800131
Elliott Hughes462e90c2018-08-21 16:10:48 -0700132/**
133 * [closelog(3)](http://man7.org/linux/man-pages/man3/closelog.3.html) does
134 * nothing on Android.
135 */
Elliott Hughesafe63602014-07-23 11:38:38 -0700136void closelog(void);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700137
138/**
139 * [openlog(3)](http://man7.org/linux/man-pages/man3/openlog.3.html) sets
zijunzhao979d39c2023-01-05 22:00:12 +0000140 * the log tag to `__prefix`, which can be NULL to return to the default of
141 * getprogname(). On Android, the other two arguments are ignored.
Elliott Hughes462e90c2018-08-21 16:10:48 -0700142 */
zijunzhao979d39c2023-01-05 22:00:12 +0000143void openlog(const char* _Nullable __prefix, int __option, int __facility);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700144
145/**
146 * [setlogmask(3)](http://man7.org/linux/man-pages/man3/setlogmask.3.html)
147 * sets which log priorities will actually be logged. See `LOG_MASK` and
148 * `LOG_UPTO`.
149 */
Elliott Hughesfaa74342017-08-11 17:34:44 -0700150int setlogmask(int __mask);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700151
152/**
153 * [syslog(3)](http://man7.org/linux/man-pages/man3/syslog.3.html) formats
154 * the printf()-like message and logs it with the given priority, unless
155 * suppressed by setlogmask(). On Android, the output goes to logcat.
156 */
zijunzhao979d39c2023-01-05 22:00:12 +0000157void syslog(int __priority, const char* _Nonnull __fmt, ...) __printflike(2, 3);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700158
159/**
160 * [vsyslog(3)](http://man7.org/linux/man-pages/man3/vsyslog.3.html) formats
161 * the vprintf()-like message and logs it with the given priority, unless
162 * suppressed by setlogmask(). On Android, the output goes to logcat.
163 */
zijunzhao979d39c2023-01-05 22:00:12 +0000164void vsyslog(int __priority, const char* _Nonnull __fmt, va_list __args) __printflike(2, 0);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800165
166__END_DECLS