3 let conf="# $FreeBSD: src/etc/syslog.conf,v 1.30.2.1 2009/08/03 08:13:06 kensmith Exp $
6 daemon.info /var/log/cvsupd.log
7 security.* -/var/log/security
8 *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
9 uucp,news.crit /var/log/spooler
11 daemon.!info /var/log/foo
12 daemon.<=info /var/log/foo
13 daemon.!<=info /var/log/foo
15 *.* @syslog.far.away:123
17 *.* @@syslog.far.away:123
20 *.* |\"/usr/bin/soft arg\"
34 daemon.info /var/log/cvsupd.log
35 +foo.example.com,bar.example.com
36 daemon.info /var/log/cvsupd.log
38 daemon.info /var/log/cvsupd.log
40 daemon.info /var/log/cvsupd.log
42 daemon.info /var/log/cvsupd.log
44 daemon.info /var/log/cvsupd.log
47 news.none;mail.none -/var/log/debug
51 test Syslog.lns get conf =
52 { "#comment" = "$FreeBSD: src/etc/syslog.conf,v 1.30.2.1 2009/08/03 08:13:06 kensmith Exp $" }
56 { "selector" { "facility" = "daemon" } { "level" = "info" } }
57 { "action" { "file" = "/var/log/cvsupd.log" } }
60 { "selector" { "facility" = "security" } { "level" = "*" } }
61 { "action" { "no_sync" } { "file" = "/var/log/security" } }
64 { "selector" { "facility" = "*" } { "level" = "notice" } }
65 { "selector" { "facility" = "authpriv" } { "level" = "none" } }
66 { "selector" { "facility" = "kern" } { "level" = "debug" } }
67 { "selector" { "facility" = "lpr" } { "level" = "info" } }
68 { "selector" { "facility" = "mail" } { "level" = "crit" } }
69 { "selector" { "facility" = "news" } { "level" = "err" } }
70 { "action" { "file" = "/var/log/messages" } }
73 { "selector" { "facility" = "uucp" } { "facility" = "news" } { "level" = "crit" } }
74 { "action" { "file" = "/var/log/spooler" } }
77 { "selector" { "facility" = "*" } { "level" = "emerg" } }
78 { "action" { "user" = "*" } }
81 { "selector" { "facility" = "daemon" } { "comparison" = "!" } { "level" = "info" } }
82 { "action" { "file" = "/var/log/foo" } }
85 { "selector" { "facility" = "daemon" } { "comparison" = "<=" } { "level" = "info" } }
86 { "action" { "file" = "/var/log/foo" } }
89 { "selector" { "facility" = "daemon" } { "comparison" = "!<=" } { "level" = "info" } }
90 { "action" { "file" = "/var/log/foo" } }
93 { "selector" { "facility" = "*" } { "level" = "*" } }
94 { "action" { "protocol" = "@" } { "hostname" = "syslog.far.away" } }
97 { "selector" { "facility" = "*" } { "level" = "*" } }
98 { "action" { "protocol" = "@" } { "hostname" = "syslog.far.away" } { "port" = "123" } }
101 { "selector" { "facility" = "*" } { "level" = "*" } }
102 { "action" { "protocol" = "@@" } { "hostname" = "syslog.far.away" } }
105 { "selector" { "facility" = "*" } { "level" = "*" } }
106 { "action" { "protocol" = "@@" } { "hostname" = "syslog.far.away" } { "port" = "123" } }
109 { "selector" { "facility" = "*" } { "level" = "*" } }
110 { "action" { "protocol" = "@" } { "hostname" = "[2001::1]" } { "port" = "514" } }
113 { "selector" { "facility" = "*" } { "level" = "*" } }
114 { "action" { "user" = "foo" } { "user" = "bar" } }
117 { "selector" { "facility" = "*" } { "level" = "*" } }
118 { "action" { "program" = "\"/usr/bin/soft arg\"" } }
121 { "program" = "startslip" }
122 { "#comment" = "get that out" }
124 { "selector" { "facility" = "*" } { "level" = "*" } }
125 { "action" { "file" = "/var/log/slip.log" } }
129 { "program" = "pppd" }
130 { "program" = "ppp" }
133 { "selector" { "facility" = "*" } { "level" = "*" } }
134 { "action" { "file" = "/var/log/ppp.log" } }
138 { "program" = "startslip" }
140 { "selector" { "facility" = "*" } { "level" = "*" } }
141 { "action" { "file" = "/var/log/slip.log" } }
146 { "program" = "startslip" }
148 { "selector" { "facility" = "*" } { "level" = "*" } }
149 { "action" { "file" = "/var/log/slip.log" } }
153 { "program" = "pppd" }
155 { "selector" { "facility" = "*" } { "level" = "*" } }
156 { "action" { "file" = "/var/log/ppp.log" } }
160 { "hostname" = "foo.example.com" }
162 { "selector" { "facility" = "daemon" } { "level" = "info" } }
163 { "action" { "file" = "/var/log/cvsupd.log" } }
167 { "hostname" = "foo.example.com" }
168 { "hostname" = "bar.example.com" }
170 { "selector" { "facility" = "daemon" } { "level" = "info" } }
171 { "action" { "file" = "/var/log/cvsupd.log" } }
175 { "hostname" = "bar.example.com" }
177 { "selector" { "facility" = "daemon" } { "level" = "info" } }
178 { "action" { "file" = "/var/log/cvsupd.log" } }
183 { "hostname" = "foo.example.com" }
185 { "selector" { "facility" = "daemon" } { "level" = "info" } }
186 { "action" { "file" = "/var/log/cvsupd.log" } }
192 { "selector" { "facility" = "daemon" } { "level" = "info" } }
193 { "action" { "file" = "/var/log/cvsupd.log" } }
199 { "selector" { "facility" = "daemon" } { "level" = "info" } }
200 { "action" { "file" = "/var/log/cvsupd.log" } } }
202 { "selector" { "facility" = "*" } { "comparison" = "=" } { "level" = "debug" } }
203 { "selector" { "facility" = "auth" } { "facility" = "authpriv" } { "level" = "none" } }
204 { "selector" { "facility" = "news" } { "level" = "none" } }
205 { "selector" { "facility" = "mail" } { "level" = "none" } }
206 { "action" { "no_sync" } { "file" = "/var/log/debug" } } }
207 { "#comment" = "!pppd" }
211 test Syslog.lns put "*.* /var\n" after
212 set "/entry[1]/action/file" "/foo"
215 (* changing file to discard *)
216 test Syslog.lns put "*.* /var\n" after
217 rm "/entry[1]/action/file" ;
218 set "/entry[1]/action/discard" ""
222 test Syslog.lns put "*.* /var\n" after
226 (* changing facility and level *)
227 test Syslog.lns put "*.* /var\n" after
228 set "/entry[1]/selector/facility" "daemon" ;
229 set "/entry[1]/selector/level" "info"
230 = "daemon.info /var\n"
232 (* insert a facility *)
233 test Syslog.lns put "daemon.* /var\n" after
234 insa "facility" "/entry/selector/facility" ;
235 set "/entry/selector/facility[2]" "mail"
236 = "daemon,mail.* /var\n"
238 (* creating an entry *)
239 test Syslog.lns put "" after
240 set "/entry/selector/facility" "daemon" ;
241 set "/entry/selector/level" "info" ;
242 set "/entry/action/file" "/var"
243 = "daemon.info\t/var\n"
245 (* inserting an entry before *)
246 test Syslog.lns put "*.* /var\n" after
247 insb "entry" "/entry" ;
248 set "/entry[1]/selector/facility" "daemon" ;
249 set "/entry[1]/selector/level" "info" ;
250 set "/entry[1]/action/file" "/foo"
251 = "daemon.info /foo\n*.*\t/var\n"
253 (* inserting an entry after *)
254 test Syslog.lns put "*.* /var\n" after
255 insa "entry" "/entry" ;
256 set "/entry[2]/selector/facility" "daemon" ;
257 set "/entry[2]/selector/level" "info" ;
258 set "/entry[2]/action/file" "/foo"
259 = "*.* /var\ndaemon.info\t/foo\n"
261 (* insert sync on a file *)
262 test Syslog.lns put "*.* /var\n" after
263 insb "no_sync" "/entry/action/file"
266 (* changing file to remote host *)
267 test Syslog.lns put "*.* /var\n" after
268 rm "/entry/action/file" ;
269 set "/entry/action/protocol" "@" ;
270 set "/entry/action/hostname" "far.far.away"
271 = "*.* @far.far.away\n"
273 (* changing file to remote host *)
274 test Syslog.lns put "*.* /var/lib\n" after
275 rm "/entry/action/file" ;
276 set "/entry/action/protocol" "@@" ;
277 set "/entry/action/hostname" "far.far.away"
278 = "*.* @@far.far.away\n"
280 (* changing file to * *)
281 test Syslog.lns put "*.* /var\n" after
282 rm "/entry/action/file" ;
283 set "/entry/action/user" "*"
286 (* changing file to users *)
287 test Syslog.lns put "*.* /var\n" after
288 rm "/entry/action/file" ;
289 set "/entry/action/user[1]" "john" ;
290 set "/entry/action/user[2]" "paul" ;
291 set "/entry/action/user[3]" "george" ;
292 set "/entry/action/user[4]" "ringo"
293 = "*.* john,paul,george,ringo\n"
295 (* changing file to program *)
296 test Syslog.lns put "*.* /var\n" after
297 rm "/entry/action/file" ;
298 set "/entry/action/program" "/usr/bin/foo"
299 = "*.* |/usr/bin/foo\n"
301 (* inserting a matching program *)
302 test Syslog.lns put "" after
304 set "/program/program" "foo"
307 (* inserting an entry to a matching program *)
308 test Syslog.lns put "!foo\n" after
309 set "/program/entry/selector/facility" "*" ;
310 set "/program/entry/selector/level" "*" ;
311 set "/program/entry/action/file" "/foo"
312 = "!foo\n*.*\t/foo\n"
314 (* inserting a matching hostname *)
315 test Syslog.lns put "" after
316 insa "hostname" "/" ;
317 set "/hostname/hostname" "foo.foo.away"
320 (* inserting an entry to a matching hostname *)
321 test Syslog.lns put "+foo.foo.away\n" after
322 set "/hostname/entry/selector/facility" "*" ;
323 set "/hostname/entry/selector/level" "*" ;
324 set "/hostname/entry/action/file" "/foo"
325 = "+foo.foo.away\n*.*\t/foo\n"
327 (* inserting a reverse matching hostname *)
328 test Syslog.lns put "" after
329 insa "hostname" "/" ;
330 set "/hostname/reverse" "" ;
331 set "/hostname/hostname" "foo.foo.away"
334 (* tokens can contain capital letters *)
335 test Syslog.lns get "LOCAL5.* -/var/log/foo.log\n" =
338 { "facility" = "LOCAL5" }
343 { "file" = "/var/log/foo.log" }
347 (* test for commented out statements *)
348 test Syslog.lns put "" after
349 set "#comment" "!pppd" = "# !pppd\n"
351 (* allow space before comments *)
352 test Syslog.lns get " \t# space comment\n" =
353 { "#comment" = "space comment" }
355 test Syslog.lns get "include /etc/syslog.d\n" =
356 { "include" = "/etc/syslog.d" }