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 logging.syslog; 17 18 version (Posix): 19 20 extern (C): 21 @system: 22 nothrow: 23 24 version(linux) 25 { 26 //PRIORITY 27 enum { 28 LOG_EMERG = 0, /* system is unusable */ 29 LOG_ALERT = 1, /* action must be taken immediately */ 30 LOG_CRIT = 2, /* critical conditions */ 31 LOG_ERR = 3, /* error conditions */ 32 LOG_WARNING = 4, /* warning conditions */ 33 LOG_NOTICE = 5, /* normal but significant condition */ 34 LOG_INFO = 6, /* informational */ 35 LOG_DEBUG = 7, /* debug-level messages */ 36 }; 37 38 //OPTIONS 39 enum { 40 LOG_PID = 0x01, /* log the pid with each message */ 41 LOG_CONS = 0x02, /* log on the console if errors in sending */ 42 LOG_ODELAY = 0x04, /* delay open until first syslog() (default) */ 43 LOG_NDELAY = 0x08, /* don't delay open */ 44 LOG_NOWAIT = 0x10, /* don't wait for console forks: DEPRECATED */ 45 LOG_PERROR = 0x20, /* log to stderr as well */ 46 }; 47 48 //FACILITY 49 enum { 50 LOG_KERN = (0<<3), /* kernel messages */ 51 LOG_USER = (1<<3), /* random user-level messages */ 52 LOG_MAIL = (2<<3), /* mail system */ 53 LOG_DAEMON = (3<<3), /* system daemons */ 54 LOG_AUTH = (4<<3), /* security/authorization messages */ 55 LOG_SYSLOG = (5<<3), /* messages generated internally by syslogd */ 56 LOG_LPR = (6<<3), /* line printer subsystem */ 57 LOG_NEWS = (7<<3), /* network news subsystem */ 58 LOG_UUCP = (8<<3), /* UUCP subsystem */ 59 LOG_CRON = (9<<3), /* clock daemon */ 60 LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */ 61 LOG_FTP = (11<<3), /* ftp daemon */ 62 63 /* other codes through 15 reserved for system use */ 64 LOG_LOCAL0 = (16<<3), /* reserved for local use */ 65 LOG_LOCAL1 = (17<<3), /* reserved for local use */ 66 LOG_LOCAL2 = (18<<3), /* reserved for local use */ 67 LOG_LOCAL3 = (19<<3), /* reserved for local use */ 68 LOG_LOCAL4 = (20<<3), /* reserved for local use */ 69 LOG_LOCAL5 = (21<<3), /* reserved for local use */ 70 LOG_LOCAL6 = (22<<3), /* reserved for local use */ 71 LOG_LOCAL7 = (23<<3), /* reserved for local use */ 72 73 LOG_NFACILITIES = 24, /* current number of facilities */ 74 }; 75 76 int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ 77 int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; } /* all priorities through pri */ 78 79 void openlog (const char *, int __option, int __facility); 80 int setlogmask (int __mask); 81 void syslog (int __pri, const char *__fmt, ...); 82 void closelog(); 83 } 84 else version( OSX ) 85 { 86 //http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/sys/syslog.h 87 88 //PRIORITY 89 enum { 90 LOG_EMERG = 0, /* system is unusable */ 91 LOG_ALERT = 1, /* action must be taken immediately */ 92 LOG_CRIT = 2, /* critical conditions */ 93 LOG_ERR = 3, /* error conditions */ 94 LOG_WARNING = 4, /* warning conditions */ 95 LOG_NOTICE = 5, /* normal but significant condition */ 96 LOG_INFO = 6, /* informational */ 97 LOG_DEBUG = 7, /* debug-level messages */ 98 }; 99 100 //OPTIONS 101 enum { 102 LOG_PID = 0x01, /* log the pid with each message */ 103 LOG_CONS = 0x02, /* log on the console if errors in sending */ 104 LOG_ODELAY = 0x04, /* delay open until first syslog() (default) */ 105 LOG_NDELAY = 0x08, /* don't delay open */ 106 LOG_NOWAIT = 0x10, /* don't wait for console forks: DEPRECATED */ 107 }; 108 109 //FACILITY 110 enum { 111 LOG_KERN = (0<<3), /* kernel messages */ 112 LOG_USER = (1<<3), /* random user-level messages */ 113 LOG_MAIL = (2<<3), /* mail system */ 114 LOG_DAEMON = (3<<3), /* system daemons */ 115 LOG_AUTH = (4<<3), /* security/authorization messages */ 116 LOG_SYSLOG = (5<<3), /* messages generated internally by syslogd */ 117 LOG_LPR = (6<<3), /* line printer subsystem */ 118 LOG_NEWS = (7<<3), /* network news subsystem */ 119 LOG_UUCP = (8<<3), /* UUCP subsystem */ 120 121 /* other codes through 15 reserved for system use */ 122 LOG_LOCAL0 = (16<<3), /* reserved for local use */ 123 LOG_LOCAL1 = (17<<3), /* reserved for local use */ 124 LOG_LOCAL2 = (18<<3), /* reserved for local use */ 125 LOG_LOCAL3 = (19<<3), /* reserved for local use */ 126 LOG_LOCAL4 = (20<<3), /* reserved for local use */ 127 LOG_LOCAL5 = (21<<3), /* reserved for local use */ 128 LOG_LOCAL6 = (22<<3), /* reserved for local use */ 129 LOG_LOCAL7 = (23<<3), /* reserved for local use */ 130 131 LOG_NFACILITIES = 24, /* current number of facilities */ 132 }; 133 134 int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ 135 int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; } /* all priorities through pri */ 136 137 void openlog (const char *, int __option, int __facility); 138 int setlogmask (int __mask); 139 void syslog (int __pri, const char *__fmt, ...); 140 void closelog(); 141 } 142 else version( FreeBSD ) 143 { 144 //http://fxr.watson.org/fxr/source/sys/syslog.h 145 146 //PRIORITY 147 enum { 148 LOG_EMERG = 0, /* system is unusable */ 149 LOG_ALERT = 1, /* action must be taken immediately */ 150 LOG_CRIT = 2, /* critical conditions */ 151 LOG_ERR = 3, /* error conditions */ 152 LOG_WARNING = 4, /* warning conditions */ 153 LOG_NOTICE = 5, /* normal but significant condition */ 154 LOG_INFO = 6, /* informational */ 155 LOG_DEBUG = 7, /* debug-level messages */ 156 }; 157 158 //OPTIONS 159 enum { 160 LOG_PID = 0x01, /* log the pid with each message */ 161 LOG_CONS = 0x02, /* log on the console if errors in sending */ 162 LOG_ODELAY = 0x04, /* delay open until first syslog() (default) */ 163 LOG_NDELAY = 0x08, /* don't delay open */ 164 LOG_NOWAIT = 0x10, /* don't wait for console forks: DEPRECATED */ 165 LOG_PERROR = 0x20, /* log to stderr as well */ 166 }; 167 168 //FACILITY 169 enum { 170 LOG_KERN = (0<<3), /* kernel messages */ 171 LOG_USER = (1<<3), /* random user-level messages */ 172 LOG_MAIL = (2<<3), /* mail system */ 173 LOG_DAEMON = (3<<3), /* system daemons */ 174 LOG_AUTH = (4<<3), /* security/authorization messages */ 175 LOG_SYSLOG = (5<<3), /* messages generated internally by syslogd */ 176 LOG_LPR = (6<<3), /* line printer subsystem */ 177 LOG_NEWS = (7<<3), /* network news subsystem */ 178 LOG_UUCP = (8<<3), /* UUCP subsystem */ 179 LOG_CRON = (9<<3), /* clock daemon */ 180 LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */ 181 LOG_FTP = (11<<3), /* ftp daemon */ 182 LOG_NTP = (12<<3), /* NTP subsystem */ 183 LOG_SECURITY = (13<<3), /* security subsystems (firewalling, etc.) */ 184 LOG_CONSOLE = (14<<3), /* /dev/console output */ 185 186 /* other codes through 15 reserved for system use */ 187 LOG_LOCAL0 = (16<<3), /* reserved for local use */ 188 LOG_LOCAL1 = (17<<3), /* reserved for local use */ 189 LOG_LOCAL2 = (18<<3), /* reserved for local use */ 190 LOG_LOCAL3 = (19<<3), /* reserved for local use */ 191 LOG_LOCAL4 = (20<<3), /* reserved for local use */ 192 LOG_LOCAL5 = (21<<3), /* reserved for local use */ 193 LOG_LOCAL6 = (22<<3), /* reserved for local use */ 194 LOG_LOCAL7 = (23<<3), /* reserved for local use */ 195 196 LOG_NFACILITIES = 24, /* current number of facilities */ 197 }; 198 199 int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ 200 int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; } /* all priorities through pri */ 201 202 void openlog (const char *, int __option, int __facility); 203 int setlogmask (int __mask); 204 void syslog (int __pri, const char *__fmt, ...); 205 void closelog(); 206 } 207 else version( Solaris ) 208 { 209 //http://pubs.opengroup.org/onlinepubs/007904875/basedefs/syslog.h.html 210 211 //PRIORITY 212 enum { 213 LOG_EMERG = 0, /* system is unusable */ 214 LOG_ALERT = 1, /* action must be taken immediately */ 215 LOG_CRIT = 2, /* critical conditions */ 216 LOG_ERR = 3, /* error conditions */ 217 LOG_WARNING = 4, /* warning conditions */ 218 LOG_NOTICE = 5, /* normal but significant condition */ 219 LOG_INFO = 6, /* informational */ 220 LOG_DEBUG = 7, /* debug-level messages */ 221 }; 222 223 //OPTIONS 224 enum { 225 LOG_PID = 0x01, /* log the pid with each message */ 226 LOG_CONS = 0x02, /* log on the console if errors in sending */ 227 LOG_NDELAY = 0x08, /* don't delay open */ 228 LOG_NOWAIT = 0x10, /* don't wait for console forks: DEPRECATED */ 229 }; 230 231 //FACILITY 232 enum { 233 LOG_KERN = (0<<3), /* kernel messages */ 234 LOG_USER = (1<<3), /* random user-level messages */ 235 LOG_MAIL = (2<<3), /* mail system */ 236 LOG_DAEMON = (3<<3), /* system daemons */ 237 LOG_AUTH = (4<<3), /* security/authorization messages */ 238 LOG_SYSLOG = (5<<3), /* messages generated internally by syslogd */ 239 LOG_LPR = (6<<3), /* line printer subsystem */ 240 LOG_NEWS = (7<<3), /* network news subsystem */ 241 LOG_UUCP = (8<<3), /* UUCP subsystem */ 242 LOG_CRON = (9<<3), /* clock daemon */ 243 LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */ 244 LOG_FTP = (11<<3), /* ftp daemon */ 245 246 /* other codes through 15 reserved for system use */ 247 LOG_LOCAL0 = (16<<3), /* reserved for local use */ 248 LOG_LOCAL1 = (17<<3), /* reserved for local use */ 249 LOG_LOCAL2 = (18<<3), /* reserved for local use */ 250 LOG_LOCAL3 = (19<<3), /* reserved for local use */ 251 LOG_LOCAL4 = (20<<3), /* reserved for local use */ 252 LOG_LOCAL5 = (21<<3), /* reserved for local use */ 253 LOG_LOCAL6 = (22<<3), /* reserved for local use */ 254 LOG_LOCAL7 = (23<<3), /* reserved for local use */ 255 256 LOG_NFACILITIES = 24, /* current number of facilities */ 257 }; 258 259 int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ 260 int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; } /* all priorities through pri */ 261 262 void openlog (const char *, int __option, int __facility); 263 int setlogmask (int __mask); 264 void syslog (int __pri, const char *__fmt, ...); 265 void closelog(); 266 }