Skip to content

Commit

Permalink
Merge pull request puppetlabs#513 from antaflos/loglevel
Browse files Browse the repository at this point in the history
Make LogLevel configurable for vhost
  • Loading branch information
igalic committed Dec 5, 2013
2 parents d24bc29 + 3ea862d commit ba05db3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -850,6 +850,10 @@ Enables an IP-based vhost. This parameter inhibits the creation of a NameVirtual

Specifies the location of the virtual host's logfiles. Defaults to `/var/log/<apache log location>/`.

#####`log_level`

Specifies the verbosity level of the error log. Defaults to `warn` for the global server configuration and can be overridden on a per-vhost basis using this parameter. Valid value for `log_level` is one of `emerg`, `alert`, `crit`, `error`, `warn`, `notice`, `info` or `debug`.

#####`no_proxy_uris`

Specifies URLs you do not want to proxy. This parameter is meant to be used in combination with `proxy_dest`.
Expand Down
10 changes: 10 additions & 0 deletions manifests/vhost.pp
Expand Up @@ -17,6 +17,9 @@
# - The $vhost_name for name based virtualhosting, defaulting to *
# - The $logroot specifies the location of the virtual hosts logfiles, default
# to /var/log/<apache log location>/
# - The $log_level specifies the verbosity of the error log for this vhost. Not
# set by default for the vhost, instead the global server configuration default
# of 'warn' is used.
# - The $access_log specifies if *_access.log directives should be configured.
# - The $ensure specifies if vhost file is present or absent.
# - The $request_headers is a list of RequestHeader statement strings as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#requestheader
Expand Down Expand Up @@ -93,6 +96,7 @@
$directoryindex = '',
$vhost_name = '*',
$logroot = $apache::logroot,
$log_level = undef,
$access_log = true,
$access_log_file = undef,
$access_log_pipe = undef,
Expand Down Expand Up @@ -164,6 +168,11 @@
validate_hash($itk)
}

if $log_level {
validate_re($log_level, '^(emerg|alert|crit|error|warn|notice|info|debug)$',
"Log level '${log_level}' is not one of the supported Apache HTTP Server log levels.")
}

if $access_log_file and $access_log_pipe {
fail("Apache::Vhost[${name}]: 'access_log_file' and 'access_log_pipe' cannot be defined at the same time")
}
Expand Down Expand Up @@ -365,6 +374,7 @@
# - $name
# - $aliases
# - $_directories
# - $log_level
# - $access_log
# - $access_log_destination
# - $_access_log_format
Expand Down
6 changes: 6 additions & 0 deletions spec/defines/vhost_spec.rb
Expand Up @@ -167,6 +167,12 @@
:value => '/fake/log',
:match => [/CustomLog \/fake\/log\//,/ErrorLog \/fake\/log\//],
},
{
:title => 'should accept log_level',
:attr => 'log_level',
:value => 'info',
:match => [/LogLevel info/],
},
{
:title => 'should accept pipe destination for access log',
:attr => 'access_log_pipe',
Expand Down
4 changes: 3 additions & 1 deletion templates/vhost.conf.erb
Expand Up @@ -35,7 +35,9 @@
<% if @error_log -%>
ErrorLog <%= @error_log_destination %>
<% end -%>
LogLevel warn
<% if @log_level -%>
LogLevel <%= @log_level %>
<% end -%>
ServerSignature Off
<% if @access_log -%>
CustomLog <%= @access_log_destination %> <%= @_access_log_format %>
Expand Down

0 comments on commit ba05db3

Please sign in to comment.