Validate log parameters

Make sure log_handlers parameter contains only supported handler names.
Empty handlers list is now rejected because we expect at least one
logger may be enabled in real deployments.

Also validate log_level and log_facility.

Change-Id: I35e2f1f232bd6b5723f61442a3e4a4ba3315547f
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-09-21 02:51:44 +09:00
parent 2decf6b742
commit 7bdc9ead83
4 changed files with 29 additions and 5 deletions

View File

@@ -596,11 +596,11 @@ class horizon (
$api_result_limit = undef,
$api_result_page_size = undef,
$dropdown_max_items = undef,
Array[String[1]] $log_handlers = ['file'],
$log_level = 'INFO',
$django_log_level = undef,
$django_template_log_level = 'INFO',
$syslog_facility = 'local1',
Horizon::LogHandlers $log_handlers = ['file'],
Horizon::LogLevel $log_level = 'INFO',
Optional[Horizon::LogLevel] $django_log_level = undef,
Horizon::LogLevel $django_template_log_level = 'INFO',
Horizon::SyslogFacility $syslog_facility = 'local1',
Optional[Stdlib::HTTPUrl] $help_url = undef,
Optional[Stdlib::HTTPUrl] $bug_url = undef,
$local_settings_template = 'horizon/local_settings.py.erb',

4
types/loghandlers.pp Normal file
View File

@@ -0,0 +1,4 @@
type Horizon::LogHandlers = Array[
Enum['null', 'console', 'file', 'syslog'],
1,
]

10
types/loglevel.pp Normal file
View File

@@ -0,0 +1,10 @@
type Horizon::LogLevel = Enum[
'NOTSET',
'DEBUG',
'INFO',
'WARNING',
'ERROR',
'CRITICAL',
'WARN',
'FATAL',
]

10
types/syslogfacility.pp Normal file
View File

@@ -0,0 +1,10 @@
type Horizon::SyslogFacility = Enum[
'local0',
'local1',
'local2',
'local3',
'local4',
'local5',
'local6',
'local7',
]