1cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh/*
2cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * Copyright (C) 2008 The Android Open Source Project
3cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * All rights reserved.
4cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *
5cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * Redistribution and use in source and binary forms, with or without
6cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * modification, are permitted provided that the following conditions
7cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * are met:
8cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *  * Redistributions of source code must retain the above copyright
9cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *    notice, this list of conditions and the following disclaimer.
10cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *  * Redistributions in binary form must reproduce the above copyright
11cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *    notice, this list of conditions and the following disclaimer in
12cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *    the documentation and/or other materials provided with the
13cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *    distribution.
14cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh *
15cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh * SUCH DAMAGE.
27cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh */
281b55d7b281f282232ee58da5d09d3da5969ff11dAndrew Hsieh
29cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh#ifndef _SYSLOG_H
30cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh#define _SYSLOG_H
31cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
32cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh#include <stdio.h>
33cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh#include <sys/cdefs.h>
34cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh#include <stdarg.h>
35cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
36cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh__BEGIN_DECLS
37cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
3870265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh/* Priorities are translated to Android log priorities as shown. */
3970265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_EMERG   0 /* ERROR */
4070265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_ALERT   1 /* ERROR */
4170265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_CRIT    2 /* ERROR */
4270265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_ERR     3 /* ERROR */
4370265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_WARNING 4 /* WARN */
4470265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_NOTICE  5 /* INFO */
4570265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_INFO    6 /* INFO */
4670265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_DEBUG   7 /* DEBUG */
47cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
4870265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_PRIMASK 7
4970265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_PRI(x) ((x) & LOG_PRIMASK)
50cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
5170265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh/* Facilities are currently ignored on Android. */
5270265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_KERN     0000
5370265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_USER     0010
5470265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_MAIL     0020
5570265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_DAEMON   0030
5670265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_AUTH     0040
5770265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_SYSLOG   0050
5870265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LPR      0060
5970265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_NEWS     0070
6070265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_UUCP     0100
6170265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_CRON     0110
6270265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_AUTHPRIV 0120
6370265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_FTP      0130
6470265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL0   0200
6570265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL1   0210
6670265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL2   0220
6770265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL3   0230
6870265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL4   0240
6970265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL5   0250
7070265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL6   0260
7170265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_LOCAL7   0270
72cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
7370265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_FACMASK 01770
7470265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_FAC(x) (((x) >> 3) & (LOG_FACMASK >> 3))
75cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
761b55d7b281f282232ee58da5d09d3da5969ff11dAndrew Hsieh#define LOG_MASK(pri) (1 << (pri))
771b55d7b281f282232ee58da5d09d3da5969ff11dAndrew Hsieh#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1)
78cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
7970265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh/* openlog(3) flags are currently ignored on Android. */
8070265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_PID    0x01
8170265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_CONS   0x02
8270265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_ODELAY 0x04
8370265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_NDELAY 0x08
8470265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_NOWAIT 0x10
8570265c95acca4be96f4c82ad80645e67fe718094Andrew Hsieh#define LOG_PERROR 0x20
86cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
8770265c95acca4be96f4c82ad80645e67fe718094Andrew Hsiehvoid closelog(void);
8870265c95acca4be96f4c82ad80645e67fe718094Andrew Hsiehvoid openlog(const char*, int, int);
8970265c95acca4be96f4c82ad80645e67fe718094Andrew Hsiehint setlogmask(int);
9070265c95acca4be96f4c82ad80645e67fe718094Andrew Hsiehvoid syslog(int, const char*, ...) __printflike(2, 3);
9170265c95acca4be96f4c82ad80645e67fe718094Andrew Hsiehvoid vsyslog(int, const char*, va_list) __printflike(2, 0);
92cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
93cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh__END_DECLS
94cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh
95cf138744ee2efefa4cd02ace5bedcdc56d750ad5Andrew Hsieh#endif /* _SYSLOG_H */
96