Skip to content

Commit

Permalink
Merge pull request voxpupuli#1253 from ekohl/logging
Browse files Browse the repository at this point in the history
Move error_log to the http section
  • Loading branch information
bastelfreak authored Oct 6, 2018
2 parents 96d52fd + 32d2f72 commit 76c96a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
22 changes: 11 additions & 11 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,22 +433,22 @@
title: 'should set error_log',
attr: 'nginx_error_log',
value: '/path/to/error.log',
match: 'error_log /path/to/error.log error;'
match: ' error_log /path/to/error.log error;'
},
{
title: 'should set multiple error_logs',
attr: 'nginx_error_log',
value: ['/path/to/error.log', 'syslog:server=localhost'],
match: [
'error_log /path/to/error.log error;',
'error_log syslog:server=localhost error;'
' error_log /path/to/error.log error;',
' error_log syslog:server=localhost error;'
]
},
{
title: 'should set error_log severity level',
attr: 'nginx_error_log_severity',
value: 'warn',
match: 'error_log /var/log/nginx/error.log warn;'
match: ' error_log /var/log/nginx/error.log warn;'
},
{
title: 'should set pid',
Expand Down Expand Up @@ -544,28 +544,28 @@
title: 'should set access_log',
attr: 'http_access_log',
value: '/path/to/access.log',
match: ' access_log /path/to/access.log;'
match: ' access_log /path/to/access.log;'
},
{
title: 'should set multiple access_logs',
attr: 'http_access_log',
value: ['/path/to/access.log', 'syslog:server=localhost'],
match: [
' access_log /path/to/access.log;',
' access_log syslog:server=localhost;'
' access_log /path/to/access.log;',
' access_log syslog:server=localhost;'
]
},
{
title: 'should set custom log format',
attr: 'http_format_log',
value: 'mycustomformat',
match: ' access_log /var/log/nginx/access.log mycustomformat;'
match: ' access_log /var/log/nginx/access.log mycustomformat;'
},
{
title: 'should set sendfile',
attr: 'sendfile',
value: 'on',
match: ' sendfile on;'
match: ' sendfile on;'
},
{
title: 'should not set sendfile',
Expand Down Expand Up @@ -1183,12 +1183,12 @@
it { is_expected.to contain_file('/foo/bar').with(ensure: 'directory') }
it do
is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(
%r{access_log /foo/bar/access.log;}
%r{access_log /foo/bar/access.log;}
)
end
it do
is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(
%r{error_log /foo/bar/error.log error;}
%r{error_log /foo/bar/error.log error;}
)
end
end
Expand Down
20 changes: 10 additions & 10 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ worker_rlimit_nofile <%= @worker_rlimit_nofile %>;
<% if @pid -%>
pid <%= @pid %>;
<% end -%>
<% if @nginx_error_log.is_a?(Array) -%>
<%- @nginx_error_log.each do |log_item| -%>
error_log <%= log_item %> <%= @nginx_error_log_severity %>;
<%- end -%>
<% else -%>
error_log <%= @nginx_error_log %> <%= @nginx_error_log_severity %>;
<% end -%>
<% if @nginx_cfg_prepend -%>

<%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
Expand Down Expand Up @@ -79,14 +72,21 @@ http {
<% end -%>
<% if @http_access_log.is_a?(Array) -%>
<%- @http_access_log.each do |log_item| -%>
access_log <%= log_item %><% if @http_format_log %> <%= @http_format_log%><% end %>;
access_log <%= log_item %><% if @http_format_log %> <%= @http_format_log%><% end %>;
<%- end -%>
<% else -%>
access_log <%= @http_access_log %><% if @http_format_log %> <%= @http_format_log%><% end %>;
<% end -%>
<% if @nginx_error_log.is_a?(Array) -%>
<%- @nginx_error_log.each do |log_item| -%>
error_log <%= log_item %> <%= @nginx_error_log_severity %>;
<%- end -%>
<% else -%>
access_log <%= @http_access_log %><% if @http_format_log %> <%= @http_format_log%><% end %>;
error_log <%= @nginx_error_log %> <%= @nginx_error_log_severity %>;
<% end -%>

<% if @sendfile == 'on' -%>
sendfile on;
sendfile on;
<%- if @http_tcp_nopush == 'on' -%>
tcp_nopush on;
<%- end -%>
Expand Down

0 comments on commit 76c96a6

Please sign in to comment.