Home | History | Annotate | Download | only in include
      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  */
     28 
     29 #pragma once
     30 
     31 #include <stdio.h>
     32 #include <sys/cdefs.h>
     33 #include <stdarg.h>
     34 
     35 __BEGIN_DECLS
     36 
     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
     53 
     54 #define LOG_PRIMASK 7
     55 #define LOG_PRI(x) ((x) & LOG_PRIMASK)
     56 #define LOG_MAKEPRI(fac, pri) ((fac) | (pri))
     57 
     58 /** Currently ignored on Android. */
     59 #define LOG_KERN     (0<<3)
     60 /** Currently ignored on Android. */
     61 #define LOG_USER     (1<<3)
     62 /** Currently ignored on Android. */
     63 #define LOG_MAIL     (2<<3)
     64 /** Currently ignored on Android. */
     65 #define LOG_DAEMON   (3<<3)
     66 /** Currently ignored on Android. */
     67 #define LOG_AUTH     (4<<3)
     68 /** Currently ignored on Android. */
     69 #define LOG_SYSLOG   (5<<3)
     70 /** Currently ignored on Android. */
     71 #define LOG_LPR      (6<<3)
     72 /** Currently ignored on Android. */
     73 #define LOG_NEWS     (7<<3)
     74 /** Currently ignored on Android. */
     75 #define LOG_UUCP     (8<<3)
     76 /** Currently ignored on Android. */
     77 #define LOG_CRON     (9<<3)
     78 /** Currently ignored on Android. */
     79 #define LOG_AUTHPRIV (10<<3)
     80 /** Currently ignored on Android. */
     81 #define LOG_FTP      (11<<3)
     82 /** Currently ignored on Android. */
     83 #define LOG_LOCAL0   (16<<3)
     84 /** Currently ignored on Android. */
     85 #define LOG_LOCAL1   (17<<3)
     86 /** Currently ignored on Android. */
     87 #define LOG_LOCAL2   (18<<3)
     88 /** Currently ignored on Android. */
     89 #define LOG_LOCAL3   (19<<3)
     90 /** Currently ignored on Android. */
     91 #define LOG_LOCAL4   (20<<3)
     92 /** Currently ignored on Android. */
     93 #define LOG_LOCAL5   (21<<3)
     94 /** Currently ignored on Android. */
     95 #define LOG_LOCAL6   (22<<3)
     96 /** Currently ignored on Android. */
     97 #define LOG_LOCAL7   (23<<3)
     98 
     99 #define LOG_NFACILITIES 24
    100 #define LOG_FACMASK 0x3f8
    101 #define LOG_FAC(x) (((x) >> 3) & (LOG_FACMASK >> 3))
    102 
    103 /**
    104  * Converts a log priority into a mask enabling that single priority,
    105  * for use with setlogmask().
    106  */
    107 #define LOG_MASK(pri) (1 << (pri))
    108 
    109 /**
    110  * Converts a log priority into a mask enabling that priority and all lower
    111  * priorities, for use with setlogmask().
    112  */
    113 #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1)
    114 
    115 /** openlog() options are currently ignored on Android. */
    116 #define LOG_PID    0x01
    117 /** openlog() options are currently ignored on Android. */
    118 #define LOG_CONS   0x02
    119 /** openlog() options are currently ignored on Android. */
    120 #define LOG_ODELAY 0x04
    121 /** openlog() options are currently ignored on Android. */
    122 #define LOG_NDELAY 0x08
    123 /** openlog() options are currently ignored on Android. */
    124 #define LOG_NOWAIT 0x10
    125 /** openlog() options are currently ignored on Android. */
    126 #define LOG_PERROR 0x20
    127 
    128 /**
    129  * [closelog(3)](http://man7.org/linux/man-pages/man3/closelog.3.html) does
    130  * nothing on Android.
    131  */
    132 void closelog(void);
    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  */
    138 void openlog(const char* __prefix, int __option, int __facility);
    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  */
    145 int setlogmask(int __mask);
    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  */
    152 void syslog(int __priority, const char* __fmt, ...) __printflike(2, 3);
    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  */
    159 void vsyslog(int __priority, const char* __fmt, va_list __args) __printflike(2, 0);
    160 
    161 __END_DECLS
    162