The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* |
| 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 Hughes | a382a79 | 2014-06-09 17:16:19 -0700 | [diff] [blame] | 28 | |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 29 | #pragma once |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 30 | |
| 31 | #include <stdio.h> |
| 32 | #include <sys/cdefs.h> |
| 33 | #include <stdarg.h> |
| 34 | |
| 35 | __BEGIN_DECLS |
| 36 | |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 37 | /** 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 Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 53 | |
Elliott Hughes | afe6360 | 2014-07-23 11:38:38 -0700 | [diff] [blame] | 54 | #define LOG_PRIMASK 7 |
| 55 | #define LOG_PRI(x) ((x) & LOG_PRIMASK) |
Mark Salyzyn | c4a586d | 2015-03-12 13:21:35 -0700 | [diff] [blame] | 56 | #define LOG_MAKEPRI(fac, pri) ((fac) | (pri)) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 57 | |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 58 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 59 | #define LOG_KERN (0<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 60 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 61 | #define LOG_USER (1<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 62 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 63 | #define LOG_MAIL (2<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 64 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 65 | #define LOG_DAEMON (3<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 66 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 67 | #define LOG_AUTH (4<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 68 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 69 | #define LOG_SYSLOG (5<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 70 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 71 | #define LOG_LPR (6<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 72 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 73 | #define LOG_NEWS (7<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 74 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 75 | #define LOG_UUCP (8<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 76 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 77 | #define LOG_CRON (9<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 78 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 79 | #define LOG_AUTHPRIV (10<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 80 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 81 | #define LOG_FTP (11<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 82 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 83 | #define LOG_LOCAL0 (16<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 84 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 85 | #define LOG_LOCAL1 (17<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 86 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 87 | #define LOG_LOCAL2 (18<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 88 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 89 | #define LOG_LOCAL3 (19<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 90 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 91 | #define LOG_LOCAL4 (20<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 92 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 93 | #define LOG_LOCAL5 (21<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 94 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 95 | #define LOG_LOCAL6 (22<<3) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 96 | /** Currently ignored on Android. */ |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 97 | #define LOG_LOCAL7 (23<<3) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 98 | |
Elliott Hughes | f517288 | 2017-08-03 14:44:13 -0700 | [diff] [blame] | 99 | #define LOG_NFACILITIES 24 |
| 100 | #define LOG_FACMASK 0x3f8 |
Elliott Hughes | afe6360 | 2014-07-23 11:38:38 -0700 | [diff] [blame] | 101 | #define LOG_FAC(x) (((x) >> 3) & (LOG_FACMASK >> 3)) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 102 | |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 103 | /** |
| 104 | * Converts a log priority into a mask enabling that single priority, |
| 105 | * for use with setlogmask(). |
| 106 | */ |
Elliott Hughes | a382a79 | 2014-06-09 17:16:19 -0700 | [diff] [blame] | 107 | #define LOG_MASK(pri) (1 << (pri)) |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 108 | |
| 109 | /** |
| 110 | * Converts a log priority into a mask enabling that priority and all lower |
| 111 | * priorities, for use with setlogmask(). |
| 112 | */ |
Elliott Hughes | a382a79 | 2014-06-09 17:16:19 -0700 | [diff] [blame] | 113 | #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 114 | |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 115 | /** openlog() options are currently ignored on Android. */ |
Elliott Hughes | 3ad8ecb | 2014-07-21 16:35:24 -0700 | [diff] [blame] | 116 | #define LOG_PID 0x01 |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 117 | /** openlog() options are currently ignored on Android. */ |
Elliott Hughes | 3ad8ecb | 2014-07-21 16:35:24 -0700 | [diff] [blame] | 118 | #define LOG_CONS 0x02 |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 119 | /** openlog() options are currently ignored on Android. */ |
Elliott Hughes | 3ad8ecb | 2014-07-21 16:35:24 -0700 | [diff] [blame] | 120 | #define LOG_ODELAY 0x04 |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 121 | /** openlog() options are currently ignored on Android. */ |
Elliott Hughes | 3ad8ecb | 2014-07-21 16:35:24 -0700 | [diff] [blame] | 122 | #define LOG_NDELAY 0x08 |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 123 | /** openlog() options are currently ignored on Android. */ |
Elliott Hughes | 3ad8ecb | 2014-07-21 16:35:24 -0700 | [diff] [blame] | 124 | #define LOG_NOWAIT 0x10 |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 125 | /** openlog() options are currently ignored on Android. */ |
Elliott Hughes | 3ad8ecb | 2014-07-21 16:35:24 -0700 | [diff] [blame] | 126 | #define LOG_PERROR 0x20 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 127 | |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 128 | /** |
| 129 | * [closelog(3)](http://man7.org/linux/man-pages/man3/closelog.3.html) does |
| 130 | * nothing on Android. |
| 131 | */ |
Elliott Hughes | afe6360 | 2014-07-23 11:38:38 -0700 | [diff] [blame] | 132 | void closelog(void); |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 133 | |
| 134 | /** |
| 135 | * [openlog(3)](http://man7.org/linux/man-pages/man3/openlog.3.html) sets |
| 136 | * the log tag to `__prefix`. On Android, the other two arguments are ignored. |
| 137 | */ |
Elliott Hughes | faa7434 | 2017-08-11 17:34:44 -0700 | [diff] [blame] | 138 | void openlog(const char* __prefix, int __option, int __facility); |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 139 | |
| 140 | /** |
| 141 | * [setlogmask(3)](http://man7.org/linux/man-pages/man3/setlogmask.3.html) |
| 142 | * sets which log priorities will actually be logged. See `LOG_MASK` and |
| 143 | * `LOG_UPTO`. |
| 144 | */ |
Elliott Hughes | faa7434 | 2017-08-11 17:34:44 -0700 | [diff] [blame] | 145 | int setlogmask(int __mask); |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 146 | |
| 147 | /** |
| 148 | * [syslog(3)](http://man7.org/linux/man-pages/man3/syslog.3.html) formats |
| 149 | * the printf()-like message and logs it with the given priority, unless |
| 150 | * suppressed by setlogmask(). On Android, the output goes to logcat. |
| 151 | */ |
Elliott Hughes | faa7434 | 2017-08-11 17:34:44 -0700 | [diff] [blame] | 152 | void syslog(int __priority, const char* __fmt, ...) __printflike(2, 3); |
Elliott Hughes | 462e90c | 2018-08-21 16:10:48 -0700 | [diff] [blame^] | 153 | |
| 154 | /** |
| 155 | * [vsyslog(3)](http://man7.org/linux/man-pages/man3/vsyslog.3.html) formats |
| 156 | * the vprintf()-like message and logs it with the given priority, unless |
| 157 | * suppressed by setlogmask(). On Android, the output goes to logcat. |
| 158 | */ |
Elliott Hughes | faa7434 | 2017-08-11 17:34:44 -0700 | [diff] [blame] | 159 | void vsyslog(int __priority, const char* __fmt, va_list __args) __printflike(2, 0); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 160 | |
| 161 | __END_DECLS |