Skip to content

Commit 50d8f22

Browse files
author
Vasileios Karakasis
authored
Merge pull request #1424 from difey/patch-1
[bugfix] Convert Syslog handler port parameter into integer
2 parents f6111d7 + c77497f commit 50d8f22

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

reframe/core/logging.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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:

unittests/test_logging.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
354368
def 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

0 commit comments

Comments
 (0)