Skip to content

Commit cacfb7c

Browse files
Merge pull request puppetlabs#2023 from alexjfisher/replace_validate_apache_log_level_function
Replace validate_apache_loglevel() with data type
2 parents 65f4f4b + 426099e commit cacfb7c

File tree

8 files changed

+54
-119
lines changed

8 files changed

+54
-119
lines changed

lib/puppet/functions/apache/validate_apache_log_level.rb

-28
This file was deleted.

lib/puppet/parser/functions/validate_apache_log_level.rb

-31
This file was deleted.

manifests/init.pp

+3-5
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195
# > **Note**: Do not configure this parameter manually without special reason.
196196
#
197197
# @param log_level
198-
# Changes the error log's verbosity. Valid options are: `alert`, `crit`, `debug`, `emerg`, `error`,
199-
# `info`, `notice` and `warn`.
198+
# Configures the apache [LogLevel](https://httpd.apache.org/docs/current/mod/core.html#loglevel) directive
199+
# which adjusts the verbosity of the messages recorded in the error logs.
200200
#
201201
# @param log_formats
202202
# Define additional `LogFormat` directives. Values: A hash, such as:
@@ -520,7 +520,7 @@
520520
$limitreqfields = '100',
521521
$logroot = $::apache::params::logroot,
522522
$logroot_mode = $::apache::params::logroot_mode,
523-
$log_level = $::apache::params::log_level,
523+
Apache::LogLevel $log_level = $::apache::params::log_level,
524524
$log_formats = {},
525525
$ssl_file = undef,
526526
$ports_file = $::apache::params::ports_file,
@@ -602,8 +602,6 @@
602602
}
603603
}
604604

605-
apache::validate_apache_log_level($log_level)
606-
607605
class { '::apache::service':
608606
service_name => $service_name,
609607
service_enable => $service_enable,

manifests/vhost.pp

+1-5
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@
17351735
$logroot_mode = undef,
17361736
$logroot_owner = undef,
17371737
$logroot_group = undef,
1738-
$log_level = undef,
1738+
Optional[Apache::LogLevel] $log_level = undef,
17391739
Boolean $access_log = true,
17401740
$access_log_file = false,
17411741
$access_log_pipe = false,
@@ -1940,10 +1940,6 @@
19401940

19411941
# Input validation begins
19421942

1943-
if $log_level {
1944-
apache::validate_apache_log_level($log_level)
1945-
}
1946-
19471943
if $access_log_file and $access_log_pipe {
19481944
fail("Apache::Vhost[${name}]: 'access_log_file' and 'access_log_pipe' cannot be defined at the same time")
19491945
}

spec/functions/validate_apache_log_level_spec.rb

-12
This file was deleted.

spec/type_aliases/loglevel_spec.rb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'spec_helper'
2+
3+
describe 'Apache::LogLevel' do
4+
[
5+
'info',
6+
'warn ssl:info',
7+
'warn mod_ssl.c:info',
8+
'warn mod_ssl.c:info',
9+
'warn ssl_module:info',
10+
'trace4',
11+
].each do |allowed_value|
12+
it { is_expected.to allow_value(allowed_value) }
13+
end
14+
15+
[
16+
'garbage',
17+
'',
18+
[],
19+
['info'],
20+
].each do |invalid_value|
21+
it { is_expected.not_to allow_value(invalid_value) }
22+
end
23+
end

spec/unit/puppet/parser/functions/validate_apache_log_level.rb

-38
This file was deleted.

types/loglevel.pp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# @summary A string that conforms to the Apache `LogLevel` syntax.
2+
#
3+
# A string that conforms to the Apache `LogLevel` syntax.
4+
# Different levels can be specified for individual apache modules.
5+
#
6+
# ie. `[module:]level [module:level] ...`
7+
#
8+
# The levels are (in order of decreasing significance):
9+
# * `emerg`
10+
# * `alert`
11+
# * `crit`
12+
# * `error`
13+
# * `warn`
14+
# * `notice`
15+
# * `info`
16+
# * `debug`
17+
# * `trace1`
18+
# * `trace2`
19+
# * `trace3`
20+
# * `trace4`
21+
# * `trace5`
22+
# * `trace6`
23+
# * `trace7`
24+
# * `trace8`
25+
#
26+
# @see https://httpd.apache.org/docs/current/mod/core.html#loglevel
27+
type Apache::LogLevel = Pattern[/(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])/]

0 commit comments

Comments
 (0)