Puppet Function: apache::validate_apache_log_level

Defined in:
lib/puppet/functions/apache/validate_apache_log_level.rb
Function type:
Ruby 4.x API

Overview

apache::validate_apache_log_level(String $log_level)Any

Perform simple validation of a string against the list of known log

levels as per http://httpd.apache.org/docs/current/mod/core.html#loglevel
    validate_apache_loglevel('info')

Modules maybe specified with their own levels like these:
    validate_apache_loglevel('warn ssl:info')
    validate_apache_loglevel('warn mod_ssl.c:info')
    validate_apache_loglevel('warn ssl_module:info')

Expected to be used from the main or vhost.
Might be used from directory too later as apache supports that

Parameters:

  • log_level (String)

Returns:

  • (Any)


12
13
14
15
16
17
18
19
20
21
# File 'lib/puppet/functions/apache/validate_apache_log_level.rb', line 12

Puppet::Functions.create_function(:'apache::validate_apache_log_level') do
  dispatch :validate_apache_log_level do
    required_param 'String', :log_level
  end

  def validate_apache_log_level(log_level)
    msg = "Log level '${log_level}' is not one of the supported Apache HTTP Server log levels."
    raise Puppet::ParseError, msg unless log_level =~ Regexp.compile('(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])')
  end
end