Support specifying log formats
This commit is contained in:
parent
b9743d3826
commit
2e221a7e0f
4 changed files with 21 additions and 0 deletions
|
@ -57,6 +57,7 @@ class nginx::config(
|
|||
$http_tcp_nodelay = 'on',
|
||||
$http_tcp_nopush = 'off',
|
||||
$keepalive_timeout = '65',
|
||||
$log_format = {},
|
||||
$mail = false,
|
||||
$multi_accept = 'off',
|
||||
$names_hash_bucket_size = '64',
|
||||
|
|
|
@ -79,6 +79,7 @@ class nginx (
|
|||
$global_group = undef,
|
||||
$global_mode = undef,
|
||||
$logdir = undef,
|
||||
$log_format = undef,
|
||||
$http_access_log = undef,
|
||||
$nginx_error_log = undef,
|
||||
$pid = undef,
|
||||
|
@ -158,6 +159,7 @@ class nginx (
|
|||
$http_tcp_nopush or
|
||||
$keepalive_timeout or
|
||||
$logdir or
|
||||
$log_format or
|
||||
$mail or
|
||||
$multi_accept or
|
||||
$names_hash_bucket_size or
|
||||
|
@ -237,6 +239,7 @@ class nginx (
|
|||
http_tcp_nopush => $http_tcp_nopush,
|
||||
keepalive_timeout => $keepalive_timeout,
|
||||
log_dir => $logdir,
|
||||
log_format => $log_format,
|
||||
mail => $mail,
|
||||
multi_accept => $multi_accept,
|
||||
names_hash_bucket_size => $names_hash_bucket_size,
|
||||
|
|
|
@ -177,6 +177,18 @@ describe 'nginx::config' do
|
|||
:value => '100',
|
||||
:match => ' worker_connections 100;',
|
||||
},
|
||||
{
|
||||
:title => 'should set log formats',
|
||||
:attr => 'log_format',
|
||||
:value => {
|
||||
'format1' => 'FORMAT1',
|
||||
'format2' => 'FORMAT2',
|
||||
},
|
||||
:match => [
|
||||
' log_format format1 \'FORMAT1\';',
|
||||
' log_format format2 \'FORMAT2\';',
|
||||
],
|
||||
},
|
||||
{
|
||||
:title => 'should set access_log',
|
||||
:attr => 'http_access_log',
|
||||
|
|
|
@ -24,6 +24,11 @@ events {
|
|||
http {
|
||||
include <%= @conf_dir %>/mime.types;
|
||||
default_type application/octet-stream;
|
||||
<% if @log_format -%>
|
||||
<% @log_format.sort_by{|k,v| k}.each do |key,value| -%>
|
||||
log_format <%= key %> '<%= value %>';
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
||||
access_log <%= @http_access_log %>;
|
||||
|
||||
|
|
Loading…
Reference in a new issue