1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2018-09-07 armink the first version 9 */ 10 11 #ifndef _SYSLOG_H_ 12 #define _SYSLOG_H_ 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 /* 19 * priorities/facilities are encoded into a single 32-bit quantity, where the 20 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility 21 * (0-big number). Both the priorities and the facilities map roughly 22 * one-to-one to strings in the syslogd(8) source code. This mapping is 23 * included in this file. 24 * 25 * priorities (these are ordered) 26 */ 27 #define LOG_EMERG 0 /* system is unusable */ 28 #define LOG_ALERT 1 /* action must be taken immediately */ 29 #define LOG_CRIT 2 /* critical conditions */ 30 #define LOG_ERR 3 /* error conditions */ 31 #define LOG_WARNING 4 /* warning conditions */ 32 #define LOG_NOTICE 5 /* normal but significant condition */ 33 #define LOG_INFO 6 /* informational */ 34 #define LOG_DEBUG 7 /* debug-level messages */ 35 36 #define LOG_PRIMASK 0x07 37 38 #define LOG_PRI(p) ((p) & LOG_PRIMASK) 39 #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) 40 41 /* facility codes */ 42 #define LOG_KERN (0<<3) /* kernel messages */ 43 #define LOG_USER (1<<3) /* random user-level messages */ 44 #define LOG_MAIL (2<<3) /* mail system */ 45 #define LOG_DAEMON (3<<3) /* system daemons */ 46 #define LOG_AUTH (4<<3) /* security/authorization messages */ 47 #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ 48 #define LOG_LPR (6<<3) /* line printer subsystem */ 49 #define LOG_NEWS (7<<3) /* network news subsystem */ 50 #define LOG_UUCP (8<<3) /* UUCP subsystem */ 51 #define LOG_CRON (9<<3) /* clock daemon */ 52 #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ 53 54 /* other codes through 15 reserved for system use */ 55 #define LOG_LOCAL0 (16<<3) /* reserved for local use */ 56 #define LOG_LOCAL1 (17<<3) /* reserved for local use */ 57 #define LOG_LOCAL2 (18<<3) /* reserved for local use */ 58 #define LOG_LOCAL3 (19<<3) /* reserved for local use */ 59 #define LOG_LOCAL4 (20<<3) /* reserved for local use */ 60 #define LOG_LOCAL5 (21<<3) /* reserved for local use */ 61 #define LOG_LOCAL6 (22<<3) /* reserved for local use */ 62 #define LOG_LOCAL7 (23<<3) /* reserved for local use */ 63 64 #define LOG_NFACILITIES 24 /* current number of facilities */ 65 #define LOG_FACMASK 0x03f8 /* mask to extract facility part */ 66 /* facility of pri */ 67 #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) 68 69 /* 70 * arguments to setlogmask. 71 */ 72 #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ 73 #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ 74 75 /* 76 * Option flags for openlog. 77 * 78 * LOG_ODELAY no longer does anything. 79 * LOG_NDELAY is the inverse of what it used to be. 80 */ 81 #define LOG_PID 0x01 /* log the pid with each message */ 82 #define LOG_CONS 0x02 /* log on the console if errors in sending */ 83 #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 84 #define LOG_NDELAY 0x08 /* don't delay open */ 85 #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 86 #define LOG_PERROR 0x20 /* log to stderr as well */ 87 88 #include <stdarg.h> 89 90 void closelog(void); 91 void openlog(const char *ident, int option, int facility); 92 int setlogmask(int mask); 93 void syslog(int priority, const char *format, ...); 94 void vsyslog(int priority, const char *format, va_list args); 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif /* _SYSLOG_H_ */ 101