File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,12 @@ def _create_syslog_handler(site_config, config_prefix):
222222 except ValueError :
223223 pass
224224 else :
225- address = (host , port )
225+ try :
226+ address = (host , int (port ))
227+ except ValueError :
228+ raise ConfigError (
229+ f'syslog address port not an integer: { port !r} '
230+ ) from None
226231
227232 facility = site_config .get (f'{ config_prefix } /facility' )
228233 try :
Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ def test_syslog_handler(temp_runtime):
337337 if platform .system () == 'Linux' :
338338 addr = '/dev/log'
339339 elif platform .system () == 'Darwin' :
340- addr = '/dev /run/syslog'
340+ addr = '/var /run/syslog'
341341 else :
342342 pytest .skip ('unknown system platform' )
343343
@@ -351,6 +351,20 @@ def test_syslog_handler(temp_runtime):
351351 rlog .getlogger ().info ('foo' )
352352
353353
354+ def test_syslog_handler_tcp_port_noint (temp_runtime ):
355+ runtime = temp_runtime ({
356+ 'level' : 'info' ,
357+ 'handlers' : [{
358+ 'type' : 'syslog' ,
359+ 'address' : 'foo.server.org:bar' ,
360+ }],
361+ 'handlers_perflog' : []
362+ })
363+ next (runtime )
364+ with pytest .raises (ConfigError , match = "not an integer: 'bar'" ):
365+ rlog .configure_logging (rt .runtime ().site_config )
366+
367+
354368def test_global_noconfig ():
355369 # This is to test the case when no configuration is set, but since the
356370 # order the unit tests are invoked is arbitrary, we emulate the
You can’t perform that action at this time.
0 commit comments