]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/lib/puppet/parser/functions/validate_apache_log_level.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / lib / puppet / parser / functions / validate_apache_log_level.rb
1 module Puppet::Parser::Functions
2   newfunction(:validate_apache_log_level, :doc => <<-'ENDHEREDOC') do |args|
3     Perform simple validation of a string against the list of known log
4     levels as per http://httpd.apache.org/docs/current/mod/core.html#loglevel
5         validate_apache_loglevel('info')
6
7     Modules maybe specified with their own levels like these:
8         validate_apache_loglevel('warn ssl:info')
9         validate_apache_loglevel('warn mod_ssl.c:info')
10         validate_apache_loglevel('warn ssl_module:info')
11
12     Expected to be used from the main or vhost.
13     
14     Might be used from directory too later as apaceh supports that
15
16     ENDHEREDOC
17     if (args.size != 1) then
18       raise Puppet::ParseError, ("validate_apache_loglevel(): wrong number of arguments (#{args.length}; must be 1)")
19     end
20
21     log_level = args[0]
22     msg = "Log level '${log_level}' is not one of the supported Apache HTTP Server log levels."
23
24     raise Puppet::ParseError, (msg) unless log_level =~ Regexp.compile('(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])')
25
26   end
27 end