1 /**
2  * D header file for POSIX system logger API.
3  * (http://pubs.opengroup.org/onlinepubs/007904875/basedefs/syslog.h.html)
4  *
5  * Copyright: Copyright Adil Baig 2013.
6  * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
7  * Authors:   Adil Baig
8  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
9  */
10 
11 /*          Copyright Adil Baig 2013.
12  * Distributed under the Boost Software License, Version 1.0.
13  *    (See accompanying file LICENSE or copy at
14  *          http://www.boost.org/LICENSE_1_0.txt)
15  */
16 module core.sys.posix.syslog;
17 
18 version (OSX)
19     version = Darwin;
20 else version (iOS)
21     version = Darwin;
22 else version (TVOS)
23     version = Darwin;
24 else version (WatchOS)
25     version = Darwin;
26 
27 version (Posix):
28 
29 extern (C) nothrow @nogc:
30 
31 version (CRuntime_Glibc)
32 {
33     //PRIORITY
34     enum {
35         LOG_EMERG = 0,     /* system is unusable */
36         LOG_ALERT = 1,     /* action must be taken immediately */
37         LOG_CRIT  = 2,     /* critical conditions */
38         LOG_ERR   = 3,     /* error conditions */
39         LOG_WARNING = 4,   /* warning conditions */
40         LOG_NOTICE  = 5,   /* normal but significant condition */
41         LOG_INFO    = 6,   /* informational */
42         LOG_DEBUG   = 7,   /* debug-level messages */
43     }
44 
45     //OPTIONS
46     enum {
47         LOG_PID    = 0x01,  /* log the pid with each message */
48         LOG_CONS   = 0x02,  /* log on the console if errors in sending */
49         LOG_ODELAY = 0x04,  /* delay open until first syslog() (default) */
50         LOG_NDELAY = 0x08,  /* don't delay open */
51         LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
52         LOG_PERROR = 0x20,  /* log to stderr as well */
53     }
54 
55     //FACILITY
56     enum {
57         LOG_KERN   = (0<<3),  /* kernel messages */
58         LOG_USER   = (1<<3),  /* random user-level messages */
59         LOG_MAIL   = (2<<3),  /* mail system */
60         LOG_DAEMON = (3<<3),  /* system daemons */
61         LOG_AUTH   = (4<<3),  /* security/authorization messages */
62         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
63         LOG_LPR    = (6<<3),  /* line printer subsystem */
64         LOG_NEWS   = (7<<3),  /* network news subsystem */
65         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
66         LOG_CRON   = (9<<3),  /* clock daemon */
67         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
68         LOG_FTP    =  (11<<3), /* ftp daemon */
69 
70         /* other codes through 15 reserved for system use */
71         LOG_LOCAL0 = (16<<3), /* reserved for local use */
72         LOG_LOCAL1 = (17<<3), /* reserved for local use */
73         LOG_LOCAL2 = (18<<3), /* reserved for local use */
74         LOG_LOCAL3 = (19<<3), /* reserved for local use */
75         LOG_LOCAL4 = (20<<3), /* reserved for local use */
76         LOG_LOCAL5 = (21<<3), /* reserved for local use */
77         LOG_LOCAL6 = (22<<3), /* reserved for local use */
78         LOG_LOCAL7 = (23<<3), /* reserved for local use */
79 
80         LOG_NFACILITIES = 24,  /* current number of facilities */
81     }
82 
83     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
84     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
85 
86     void openlog (const char *, int __option, int __facility);
87     int  setlogmask (int __mask);
88     void syslog (int __pri, const char *__fmt, ...);
89     void closelog();
90 }
91 else version (Darwin)
92 {
93     //http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/sys/syslog.h
94 
95     //PRIORITY
96     enum {
97         LOG_EMERG = 0,     /* system is unusable */
98         LOG_ALERT = 1,     /* action must be taken immediately */
99         LOG_CRIT  = 2,     /* critical conditions */
100         LOG_ERR   = 3,     /* error conditions */
101         LOG_WARNING = 4,   /* warning conditions */
102         LOG_NOTICE  = 5,   /* normal but significant condition */
103         LOG_INFO    = 6,   /* informational */
104         LOG_DEBUG   = 7,   /* debug-level messages */
105     }
106 
107     //OPTIONS
108     enum {
109         LOG_PID    = 0x01,     /* log the pid with each message */
110         LOG_CONS   = 0x02,  /* log on the console if errors in sending */
111         LOG_ODELAY = 0x04,  /* delay open until first syslog() (default) */
112         LOG_NDELAY = 0x08,  /* don't delay open */
113         LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
114     }
115 
116     //FACILITY
117     enum {
118         LOG_KERN   = (0<<3),  /* kernel messages */
119         LOG_USER   = (1<<3),  /* random user-level messages */
120         LOG_MAIL   = (2<<3),  /* mail system */
121         LOG_DAEMON = (3<<3),  /* system daemons */
122         LOG_AUTH   = (4<<3),  /* security/authorization messages */
123         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
124         LOG_LPR    = (6<<3),  /* line printer subsystem */
125         LOG_NEWS   = (7<<3),  /* network news subsystem */
126         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
127 
128         /* other codes through 15 reserved for system use */
129         LOG_LOCAL0 = (16<<3), /* reserved for local use */
130         LOG_LOCAL1 = (17<<3), /* reserved for local use */
131         LOG_LOCAL2 = (18<<3), /* reserved for local use */
132         LOG_LOCAL3 = (19<<3), /* reserved for local use */
133         LOG_LOCAL4 = (20<<3), /* reserved for local use */
134         LOG_LOCAL5 = (21<<3), /* reserved for local use */
135         LOG_LOCAL6 = (22<<3), /* reserved for local use */
136         LOG_LOCAL7 = (23<<3), /* reserved for local use */
137 
138         LOG_NFACILITIES = 24,  /* current number of facilities */
139     }
140 
141     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
142     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
143 
144     void openlog (const char *, int __option, int __facility);
145     int  setlogmask (int __mask);
146     void syslog (int __pri, const char *__fmt, ...);
147     void closelog();
148 }
149 else version (FreeBSD)
150 {
151     //http://fxr.watson.org/fxr/source/sys/syslog.h
152 
153     //PRIORITY
154     enum {
155         LOG_EMERG = 0,     /* system is unusable */
156         LOG_ALERT = 1,     /* action must be taken immediately */
157         LOG_CRIT  = 2,     /* critical conditions */
158         LOG_ERR   = 3,     /* error conditions */
159         LOG_WARNING = 4,   /* warning conditions */
160         LOG_NOTICE  = 5,   /* normal but significant condition */
161         LOG_INFO    = 6,   /* informational */
162         LOG_DEBUG   = 7,   /* debug-level messages */
163     }
164 
165     //OPTIONS
166     enum {
167         LOG_PID    = 0x01,    /* log the pid with each message */
168         LOG_CONS   = 0x02,    /* log on the console if errors in sending */
169         LOG_ODELAY = 0x04,    /* delay open until first syslog() (default) */
170         LOG_NDELAY = 0x08,    /* don't delay open */
171         LOG_NOWAIT = 0x10,    /* don't wait for console forks: DEPRECATED */
172         LOG_PERROR = 0x20,    /* log to stderr as well */
173     }
174 
175     //FACILITY
176     enum {
177         LOG_KERN   = (0<<3),  /* kernel messages */
178         LOG_USER   = (1<<3),  /* random user-level messages */
179         LOG_MAIL   = (2<<3),  /* mail system */
180         LOG_DAEMON = (3<<3),  /* system daemons */
181         LOG_AUTH   = (4<<3),  /* security/authorization messages */
182         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
183         LOG_LPR    = (6<<3),  /* line printer subsystem */
184         LOG_NEWS   = (7<<3),  /* network news subsystem */
185         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
186         LOG_CRON   = (9<<3),  /* clock daemon */
187         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
188         LOG_FTP    =  (11<<3), /* ftp daemon */
189         LOG_NTP    = (12<<3), /* NTP subsystem */
190         LOG_SECURITY = (13<<3), /* security subsystems (firewalling, etc.) */
191         LOG_CONSOLE  = (14<<3), /* /dev/console output */
192 
193         /* other codes through 15 reserved for system use */
194         LOG_LOCAL0 = (16<<3), /* reserved for local use */
195         LOG_LOCAL1 = (17<<3), /* reserved for local use */
196         LOG_LOCAL2 = (18<<3), /* reserved for local use */
197         LOG_LOCAL3 = (19<<3), /* reserved for local use */
198         LOG_LOCAL4 = (20<<3), /* reserved for local use */
199         LOG_LOCAL5 = (21<<3), /* reserved for local use */
200         LOG_LOCAL6 = (22<<3), /* reserved for local use */
201         LOG_LOCAL7 = (23<<3), /* reserved for local use */
202 
203         LOG_NFACILITIES = 24,  /* current number of facilities */
204     }
205 
206     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
207     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
208 
209     void openlog (const char *, int __option, int __facility);
210     int  setlogmask (int __mask);
211     void syslog (int __pri, const char *__fmt, ...);
212     void closelog();
213 }
214 else version (NetBSD)
215 {
216     //http://fxr.watson.org/fxr/source/sys/syslog.h
217 
218     //PRIORITY
219     enum {
220         LOG_EMERG = 0,     /* system is unusable */
221         LOG_ALERT = 1,     /* action must be taken immediately */
222         LOG_CRIT  = 2,     /* critical conditions */
223         LOG_ERR   = 3,     /* error conditions */
224         LOG_WARNING = 4,   /* warning conditions */
225         LOG_NOTICE  = 5,   /* normal but significant condition */
226         LOG_INFO    = 6,   /* informational */
227         LOG_DEBUG   = 7,   /* debug-level messages */
228     }
229 
230     //OPTIONS
231     enum {
232         LOG_PID    = 0x01,    /* log the pid with each message */
233         LOG_CONS   = 0x02,    /* log on the console if errors in sending */
234         LOG_ODELAY = 0x04,    /* delay open until first syslog() (default) */
235         LOG_NDELAY = 0x08,    /* don't delay open */
236         LOG_NOWAIT = 0x10,    /* don't wait for console forks: DEPRECATED */
237         LOG_PERROR = 0x20,    /* log to stderr as well */
238     }
239 
240     //FACILITY
241     enum {
242         LOG_KERN   = (0<<3),  /* kernel messages */
243         LOG_USER   = (1<<3),  /* random user-level messages */
244         LOG_MAIL   = (2<<3),  /* mail system */
245         LOG_DAEMON = (3<<3),  /* system daemons */
246         LOG_AUTH   = (4<<3),  /* security/authorization messages */
247         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
248         LOG_LPR    = (6<<3),  /* line printer subsystem */
249         LOG_NEWS   = (7<<3),  /* network news subsystem */
250         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
251         LOG_CRON   = (9<<3),  /* clock daemon */
252         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
253         LOG_FTP    =  (11<<3), /* ftp daemon */
254         LOG_NTP    = (12<<3), /* NTP subsystem */
255         LOG_SECURITY = (13<<3), /* security subsystems (firewalling, etc.) */
256         LOG_CONSOLE  = (14<<3), /* /dev/console output */
257 
258         /* other codes through 15 reserved for system use */
259         LOG_LOCAL0 = (16<<3), /* reserved for local use */
260         LOG_LOCAL1 = (17<<3), /* reserved for local use */
261         LOG_LOCAL2 = (18<<3), /* reserved for local use */
262         LOG_LOCAL3 = (19<<3), /* reserved for local use */
263         LOG_LOCAL4 = (20<<3), /* reserved for local use */
264         LOG_LOCAL5 = (21<<3), /* reserved for local use */
265         LOG_LOCAL6 = (22<<3), /* reserved for local use */
266         LOG_LOCAL7 = (23<<3), /* reserved for local use */
267 
268         LOG_NFACILITIES = 24,  /* current number of facilities */
269     }
270 
271     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
272     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
273 
274     void openlog (const char *, int __option, int __facility);
275     int  setlogmask (int __mask);
276     void syslog (int __pri, const char *__fmt, ...);
277     void closelog();
278 }
279 else version (OpenBSD)
280 {
281     //PRIORITY
282     enum
283     {
284         LOG_EMERG = 0,     /* system is unusable */
285         LOG_ALERT = 1,     /* action must be taken immediately */
286         LOG_CRIT  = 2,     /* critical conditions */
287         LOG_ERR   = 3,     /* error conditions */
288         LOG_WARNING = 4,   /* warning conditions */
289         LOG_NOTICE  = 5,   /* normal but significant condition */
290         LOG_INFO    = 6,   /* informational */
291         LOG_DEBUG   = 7,   /* debug-level messages */
292     }
293 
294     //OPTIONS
295     enum
296     {
297         LOG_PID    = 0x01,    /* log the pid with each message */
298         LOG_CONS   = 0x02,    /* log on the console if errors in sending */
299         LOG_ODELAY = 0x04,    /* delay open until first syslog() (default) */
300         LOG_NDELAY = 0x08,    /* don't delay open */
301         LOG_NOWAIT = 0x10,    /* don't wait for console forks: DEPRECATED */
302         LOG_PERROR = 0x20,    /* log to stderr as well */
303     }
304 
305     //FACILITY
306     enum
307     {
308         LOG_KERN   = (0<<3),  /* kernel messages */
309         LOG_USER   = (1<<3),  /* random user-level messages */
310         LOG_MAIL   = (2<<3),  /* mail system */
311         LOG_DAEMON = (3<<3),  /* system daemons */
312         LOG_AUTH   = (4<<3),  /* security/authorization messages */
313         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
314         LOG_LPR    = (6<<3),  /* line printer subsystem */
315         LOG_NEWS   = (7<<3),  /* network news subsystem */
316         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
317         LOG_CRON   = (9<<3),  /* clock daemon */
318         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
319         LOG_FTP    =  (11<<3), /* ftp daemon */
320         // OpenBSD does not define the following:
321         //LOG_NTP
322         //LOG_SECURITY
323         //LOG_CONSOLE
324 
325         /* other codes through 15 reserved for system use */
326         LOG_LOCAL0 = (16<<3), /* reserved for local use */
327         LOG_LOCAL1 = (17<<3), /* reserved for local use */
328         LOG_LOCAL2 = (18<<3), /* reserved for local use */
329         LOG_LOCAL3 = (19<<3), /* reserved for local use */
330         LOG_LOCAL4 = (20<<3), /* reserved for local use */
331         LOG_LOCAL5 = (21<<3), /* reserved for local use */
332         LOG_LOCAL6 = (22<<3), /* reserved for local use */
333         LOG_LOCAL7 = (23<<3), /* reserved for local use */
334 
335         LOG_NFACILITIES = 24,  /* current number of facilities */
336     }
337 
338     extern(D) int LOG_MASK(int pri) { return 1 << pri; }            /* mask for one priority */
339     extern(D) int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
340 
341     void openlog(const char *, int, int);
342     int  setlogmask(int);
343     void syslog(int, const char *, ...);
344     void closelog();
345 }
346 else version (DragonFlyBSD)
347 {
348     //PRIORITY
349     enum {
350         LOG_EMERG = 0,     /* system is unusable */
351         LOG_ALERT = 1,     /* action must be taken immediately */
352         LOG_CRIT  = 2,     /* critical conditions */
353         LOG_ERR   = 3,     /* error conditions */
354         LOG_WARNING = 4,   /* warning conditions */
355         LOG_NOTICE  = 5,   /* normal but significant condition */
356         LOG_INFO    = 6,   /* informational */
357         LOG_DEBUG   = 7,   /* debug-level messages */
358     }
359 
360     //OPTIONS
361     enum {
362         LOG_PID    = 0x01,    /* log the pid with each message */
363         LOG_CONS   = 0x02,    /* log on the console if errors in sending */
364         LOG_ODELAY = 0x04,    /* delay open until first syslog() (default) */
365         LOG_NDELAY = 0x08,    /* don't delay open */
366         LOG_NOWAIT = 0x10,    /* don't wait for console forks: DEPRECATED */
367         LOG_PERROR = 0x20,    /* log to stderr as well */
368     }
369 
370     //FACILITY
371     enum {
372         LOG_KERN   = (0<<3),  /* kernel messages */
373         LOG_USER   = (1<<3),  /* random user-level messages */
374         LOG_MAIL   = (2<<3),  /* mail system */
375         LOG_DAEMON = (3<<3),  /* system daemons */
376         LOG_AUTH   = (4<<3),  /* security/authorization messages */
377         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
378         LOG_LPR    = (6<<3),  /* line printer subsystem */
379         LOG_NEWS   = (7<<3),  /* network news subsystem */
380         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
381         LOG_CRON   = (9<<3),  /* clock daemon */
382         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
383         LOG_FTP    =  (11<<3), /* ftp daemon */
384         LOG_NTP    = (12<<3), /* NTP subsystem */
385         LOG_SECURITY = (13<<3), /* security subsystems (firewalling, etc.) */
386         LOG_CONSOLE  = (14<<3), /* /dev/console output */
387 
388         /* other codes through 15 reserved for system use */
389         LOG_LOCAL0 = (16<<3), /* reserved for local use */
390         LOG_LOCAL1 = (17<<3), /* reserved for local use */
391         LOG_LOCAL2 = (18<<3), /* reserved for local use */
392         LOG_LOCAL3 = (19<<3), /* reserved for local use */
393         LOG_LOCAL4 = (20<<3), /* reserved for local use */
394         LOG_LOCAL5 = (21<<3), /* reserved for local use */
395         LOG_LOCAL6 = (22<<3), /* reserved for local use */
396         LOG_LOCAL7 = (23<<3), /* reserved for local use */
397 
398         LOG_NFACILITIES = 24,  /* current number of facilities */
399     }
400 
401     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
402     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
403 
404     void openlog (const char *, int __option, int __facility);
405     int  setlogmask (int __mask);
406     void syslog (int __pri, const char *__fmt, ...);
407     void closelog();
408 }
409 else version (Solaris)
410 {
411     //http://pubs.opengroup.org/onlinepubs/007904875/basedefs/syslog.h.html
412 
413     //PRIORITY
414     enum {
415         LOG_EMERG = 0,     /* system is unusable */
416         LOG_ALERT = 1,     /* action must be taken immediately */
417         LOG_CRIT  = 2,     /* critical conditions */
418         LOG_ERR   = 3,     /* error conditions */
419         LOG_WARNING = 4,   /* warning conditions */
420         LOG_NOTICE  = 5,   /* normal but significant condition */
421         LOG_INFO    = 6,   /* informational */
422         LOG_DEBUG   = 7,   /* debug-level messages */
423     }
424 
425     //OPTIONS
426     enum {
427         LOG_PID = 0x01,     /* log the pid with each message */
428         LOG_CONS   = 0x02,  /* log on the console if errors in sending */
429         LOG_NDELAY = 0x08,  /* don't delay open */
430         LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
431     }
432 
433     //FACILITY
434     enum {
435         LOG_KERN   = (0<<3),  /* kernel messages */
436         LOG_USER   = (1<<3),  /* random user-level messages */
437         LOG_MAIL   = (2<<3),  /* mail system */
438         LOG_DAEMON = (3<<3),  /* system daemons */
439         LOG_AUTH   = (4<<3),  /* security/authorization messages */
440         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
441         LOG_LPR    = (6<<3),  /* line printer subsystem */
442         LOG_NEWS   = (7<<3),  /* network news subsystem */
443         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
444         LOG_CRON   = (9<<3),  /* clock daemon */
445         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
446         LOG_FTP    =  (11<<3), /* ftp daemon */
447 
448         /* other codes through 15 reserved for system use */
449         LOG_LOCAL0 = (16<<3), /* reserved for local use */
450         LOG_LOCAL1 = (17<<3), /* reserved for local use */
451         LOG_LOCAL2 = (18<<3), /* reserved for local use */
452         LOG_LOCAL3 = (19<<3), /* reserved for local use */
453         LOG_LOCAL4 = (20<<3), /* reserved for local use */
454         LOG_LOCAL5 = (21<<3), /* reserved for local use */
455         LOG_LOCAL6 = (22<<3), /* reserved for local use */
456         LOG_LOCAL7 = (23<<3), /* reserved for local use */
457 
458         LOG_NFACILITIES = 24,  /* current number of facilities */
459     }
460 
461     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
462     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
463 
464     void openlog (const char *, int __option, int __facility);
465     int  setlogmask (int __mask);
466     void syslog (int __pri, const char *__fmt, ...);
467     void closelog();
468 }
469 else version (CRuntime_UClibc)
470 {
471     //PRIORITY
472     enum {
473         LOG_EMERG = 0,     /* system is unusable */
474         LOG_ALERT = 1,     /* action must be taken immediately */
475         LOG_CRIT  = 2,     /* critical conditions */
476         LOG_ERR   = 3,     /* error conditions */
477         LOG_WARNING = 4,   /* warning conditions */
478         LOG_NOTICE  = 5,   /* normal but significant condition */
479         LOG_INFO    = 6,   /* informational */
480         LOG_DEBUG   = 7,   /* debug-level messages */
481     }
482 
483     //OPTIONS
484     enum {
485         LOG_PID    = 0x01,  /* log the pid with each message */
486         LOG_CONS   = 0x02,  /* log on the console if errors in sending */
487         LOG_ODELAY = 0x04,  /* delay open until first syslog() (default) */
488         LOG_NDELAY = 0x08,  /* don't delay open */
489         LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
490         LOG_PERROR = 0x20,  /* log to stderr as well */
491     }
492 
493     //FACILITY
494     enum {
495         LOG_KERN   = (0<<3),  /* kernel messages */
496         LOG_USER   = (1<<3),  /* random user-level messages */
497         LOG_MAIL   = (2<<3),  /* mail system */
498         LOG_DAEMON = (3<<3),  /* system daemons */
499         LOG_AUTH   = (4<<3),  /* security/authorization messages */
500         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
501         LOG_LPR    = (6<<3),  /* line printer subsystem */
502         LOG_NEWS   = (7<<3),  /* network news subsystem */
503         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
504         LOG_CRON   = (9<<3),  /* clock daemon */
505         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
506         LOG_FTP    =  (11<<3), /* ftp daemon */
507 
508         /* other codes through 15 reserved for system use */
509         LOG_LOCAL0 = (16<<3), /* reserved for local use */
510         LOG_LOCAL1 = (17<<3), /* reserved for local use */
511         LOG_LOCAL2 = (18<<3), /* reserved for local use */
512         LOG_LOCAL3 = (19<<3), /* reserved for local use */
513         LOG_LOCAL4 = (20<<3), /* reserved for local use */
514         LOG_LOCAL5 = (21<<3), /* reserved for local use */
515         LOG_LOCAL6 = (22<<3), /* reserved for local use */
516         LOG_LOCAL7 = (23<<3), /* reserved for local use */
517 
518         LOG_NFACILITIES = 24,  /* current number of facilities */
519     }
520 
521     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
522     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
523 
524     void openlog (const char *, int __option, int __facility);
525     int  setlogmask (int __mask);
526     void syslog (int __pri, const char *__fmt, ...);
527     void closelog();
528 }
529 else version (CRuntime_Musl)
530 {
531     //PRIORITY
532     enum {
533         LOG_EMERG = 0,     /* system is unusable */
534         LOG_ALERT = 1,     /* action must be taken immediately */
535         LOG_CRIT  = 2,     /* critical conditions */
536         LOG_ERR   = 3,     /* error conditions */
537         LOG_WARNING = 4,   /* warning conditions */
538         LOG_NOTICE  = 5,   /* normal but significant condition */
539         LOG_INFO    = 6,   /* informational */
540         LOG_DEBUG   = 7,   /* debug-level messages */
541     }
542 
543     //OPTIONS
544     enum {
545         LOG_PID    = 0x01,  /* log the pid with each message */
546         LOG_CONS   = 0x02,  /* log on the console if errors in sending */
547         LOG_ODELAY = 0x04,  /* delay open until first syslog() (default) */
548         LOG_NDELAY = 0x08,  /* don't delay open */
549         LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
550         LOG_PERROR = 0x20,  /* log to stderr as well */
551     }
552 
553     //FACILITY
554     enum {
555         LOG_KERN   = (0<<3),  /* kernel messages */
556         LOG_USER   = (1<<3),  /* random user-level messages */
557         LOG_MAIL   = (2<<3),  /* mail system */
558         LOG_DAEMON = (3<<3),  /* system daemons */
559         LOG_AUTH   = (4<<3),  /* security/authorization messages */
560         LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
561         LOG_LPR    = (6<<3),  /* line printer subsystem */
562         LOG_NEWS   = (7<<3),  /* network news subsystem */
563         LOG_UUCP   = (8<<3),  /* UUCP subsystem */
564         LOG_CRON   = (9<<3),  /* clock daemon */
565         LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
566         LOG_FTP    =  (11<<3), /* ftp daemon */
567 
568         /* other codes through 15 reserved for system use */
569         LOG_LOCAL0 = (16<<3), /* reserved for local use */
570         LOG_LOCAL1 = (17<<3), /* reserved for local use */
571         LOG_LOCAL2 = (18<<3), /* reserved for local use */
572         LOG_LOCAL3 = (19<<3), /* reserved for local use */
573         LOG_LOCAL4 = (20<<3), /* reserved for local use */
574         LOG_LOCAL5 = (21<<3), /* reserved for local use */
575         LOG_LOCAL6 = (22<<3), /* reserved for local use */
576         LOG_LOCAL7 = (23<<3), /* reserved for local use */
577 
578         LOG_NFACILITIES = 24,  /* current number of facilities */
579     }
580 
581     int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
582     int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
583 
584     void openlog (const char *, int __option, int __facility);
585     int  setlogmask (int __mask);
586     void syslog (int __pri, const char *__fmt, ...);
587     void closelog();
588 }