1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 /*
24  * posix syslog interface definitions
25  */
26 
27 #ifndef _SYSLOG_H
28 #define _SYSLOG_H
29 
30 #include <stdarg.h>
31 
32 #define LOG_PRIBITS	3	/* priority bits			*/
33 #define LOG_FACBITS	7	/* facility bits			*/
34 
35 #define LOG_PRIMASK	((1<<LOG_PRIBITS)-1)
36 #define LOG_FACMASK	(((1<<LOG_FACBITS)-1)<<LOG_PRIBITS)
37 
38 #define LOG_PRI(p)	((p)&((1<<LOG_PRIBITS)-1))
39 #define LOG_FAC(p)	(((p)>>LOG_PRIBITS)&((1<<LOG_FACBITS)-1))
40 
41 #define LOG_MAKEPRI(f,p) (((f)<<LOG_PRIBITS)|(p))
42 
43 /* syslog priority severity levels */
44 
45 #define LOG_EMERG	0	/* panic condition			*/
46 #define LOG_ALERT	1	/* should be corrected immediately	*/
47 #define LOG_CRIT	2	/* critical condition			*/
48 #define LOG_ERR		3	/* error condition			*/
49 #define LOG_WARNING	4	/* warning condition			*/
50 #define LOG_NOTICE	5	/* no error but may need intervention	*/
51 #define LOG_INFO	6	/* informational message		*/
52 #define LOG_DEBUG	7	/* debug message			*/
53 
54 /* setlogmask masks */
55 
56 #define	LOG_MASK(s)	(1<<(s))	/* individual severity s	*/
57 #define	LOG_UPTO(s)	((1<<((s)+1))-1)/* up to and including s	*/
58 
59 /* syslog facilities */
60 
61 #define LOG_KERN	(0<<LOG_PRIBITS) /* kernel			*/
62 #define LOG_USER	(1<<LOG_PRIBITS) /* user process -- default	*/
63 #define LOG_MAIL	(2<<LOG_PRIBITS) /* mail			*/
64 #define LOG_DAEMON	(3<<LOG_PRIBITS) /* daemon			*/
65 #define LOG_AUTH	(4<<LOG_PRIBITS) /* security/authorization	*/
66 #define LOG_SYSLOG	(5<<LOG_PRIBITS) /* syslog internal		*/
67 #define LOG_LPR		(6<<LOG_PRIBITS) /* line printer		*/
68 #define LOG_NEWS	(7<<LOG_PRIBITS) /* network news		*/
69 #define LOG_UUCP	(8<<LOG_PRIBITS) /* uucp			*/
70 #define LOG_CRON	(9<<LOG_PRIBITS) /* cron			*/
71 #define LOG_AUDIT	(13<<LOG_PRIBITS) /* audit daemon		*/
72 #define LOG_LFMT	(14<<LOG_PRIBITS) /* logalert			*/
73 #define LOG_LOCAL0	(16<<LOG_PRIBITS) /* reserved for local use	*/
74 #define LOG_LOCAL1	(17<<LOG_PRIBITS) /* reserved for local use	*/
75 #define LOG_LOCAL2	(18<<LOG_PRIBITS) /* reserved for local use	*/
76 #define LOG_LOCAL3	(19<<LOG_PRIBITS) /* reserved for local use	*/
77 #define LOG_LOCAL4	(20<<LOG_PRIBITS) /* reserved for local use	*/
78 #define LOG_LOCAL5	(21<<LOG_PRIBITS) /* reserved for local use	*/
79 #define LOG_LOCAL6	(22<<LOG_PRIBITS) /* reserved for local use	*/
80 #define LOG_LOCAL7	(23<<LOG_PRIBITS) /* reserved for local use	*/
81 
82 #define LOG_NFACILITIES	24
83 
84 /* openlog flags */
85 
86 #define	LOG_PID		0x01	/* log the pid with each message	*/
87 #define	LOG_CONS	0x02	/* log to console if errors in sending	*/
88 #define LOG_NDELAY	0x08	/* open right now			*/
89 #define	LOG_ODELAY	0x04	/* delay open until syslog() is called	*/
90 #define LOG_NOWAIT	0x10	/* don't wait() for any child processes	*/
91 #define LOG_PERROR	0x20	/* log to stderr too			*/
92 #define LOG_LEVEL	0x40	/* tag messages with facility/level	*/
93 
94 #ifdef LOG_TABLES
95 
96 /* encoding support */
97 
98 #include <ast_namval.h>
99 
100 #define log_facility	_log_facility
101 #define log_severity	_log_severity
102 
103 #define LOG_FACILITY(p)	LOG_FAC(p)	/* get facility index from pri	*/
104 #define LOG_SEVERITY(p)	LOG_PRI(p)	/* get severity from pri	*/
105 
106 #if _BLD_ast && defined(__EXPORT__)
107 #define extern		__EXPORT__
108 #endif
109 #if !_BLD_ast && defined(__IMPORT__)
110 #define extern		extern __IMPORT__
111 #endif
112 
113 extern const Namval_t	log_facility[];
114 extern const Namval_t	log_severity[];
115 
116 #undef	extern
117 
118 #endif
119 
120 #if _BLD_ast && defined(__EXPORT__)
121 #define extern		__EXPORT__
122 #endif
123 
124 extern void	closelog(void);
125 extern void	openlog(const char*, int, int);
126 extern int	setlogmask(int);
127 extern void	syslog(int, const char*, ...);
128 extern void	vsyslog(int, const char*, va_list);
129 
130 #undef	extern
131 
132 #endif
133