Skip to content

Commit

Permalink
fixes #1416
Browse files Browse the repository at this point in the history
  • Loading branch information
Enrice committed May 22, 2024
1 parent 7f3a8ae commit ba33bcc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
6 changes: 4 additions & 2 deletions manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@
# server stanza, rather than setting a default. Can also be disabled for this
# server with the string 'off'.
# @param error_log
# Where to write error log. May add additional options like error level to
# the end. May set to 'absent', in which case it will be omitted in this
# Where to write error log. May set to 'absent', in which case it will be omitted in this
# server stanza (and default to nginx.conf setting)
# @param error_log_severity
# Optional error level. Defaults to nginx.conf setting
# @param passenger_cgi_param
# Allows one to define additional CGI environment variables to pass to the backend application
# @param passenger_set_header
Expand Down Expand Up @@ -399,6 +400,7 @@
Optional[Array[String]] $include_files = undef,
Optional[Variant[String, Array]] $access_log = undef,
Optional[Variant[String, Array]] $error_log = undef,
Optional[Nginx::ErrorLogSeverity] $error_log_severity = $nginx::nginx_error_log_severity,
Optional[String] $format_log = $nginx::http_format_log,
Optional[Hash] $passenger_cgi_param = undef,
Optional[Hash] $passenger_set_header = undef,
Expand Down
24 changes: 24 additions & 0 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,18 @@
' error_log syslog:server=localhost;'
]
},
{
title: 'should set error_log severity level',
attr: 'error_log_severity',
value: 'warn',
match: ' error_log /path/to/error.log warn;'
},
{
title: 'should not set error_log severity level',
attr: 'error_log_severity',
value: :undef,
match: ' error_log /path/to/error.log;'
},
{
title: 'should not include error_log in server when set to absent',
attr: 'error_log',
Expand Down Expand Up @@ -1017,6 +1029,18 @@
' error_log syslog:server=localhost;'
]
},
{
title: 'should set error_log severity level',
attr: 'error_log_severity',
value: 'warn',
match: ' error_log /path/to/error.log warn;'
},
{
title: 'should not set error_log severity level',
attr: 'error_log_severity',
value: :undef,
match: ' error_log /path/to/error.log;'
},
{
title: 'should not include error_log in server when set to absent',
attr: 'error_log',
Expand Down
6 changes: 3 additions & 3 deletions templates/server/server_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ server {
<% end -%>
<% if @error_log.is_a?(Array) -%>
<%- @error_log.each do |log_item| -%>
error_log <%= log_item %>;
error_log <%= log_item %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<%- end -%>
<% elsif @error_log == 'absent' -%>
<% elsif not @error_log -%>
error_log <%= scope['::nginx::config::log_dir'] %>/<%= @name_sanitized %>.error.log;
error_log <%= scope['::nginx::config::log_dir'] %>/<%= @name_sanitized %>.error.log<% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% else -%>
error_log <%= @error_log %>;
error_log <%= @error_log %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% end -%>
<% if @error_pages -%>

Expand Down
6 changes: 3 additions & 3 deletions templates/server/server_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ server {
<% end -%>
<% if @error_log.is_a?(Array) -%>
<%- @error_log.each do |log_item| -%>
error_log <%= log_item %>;
error_log <%= log_item %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<%- end -%>
<% elsif @error_log == 'absent' -%>
<% elsif not @error_log -%>
error_log <%= scope['::nginx::config::log_dir'] %>/ssl-<%= @name_sanitized %>.error.log;
error_log <%= scope['::nginx::config::log_dir'] %>/ssl-<%= @name_sanitized %>.error.log<% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% else -%>
error_log <%= @error_log %>;
error_log <%= @error_log %><% if @error_log_severity %> <%= @error_log_severity %><% end %>;
<% end -%>
<% if @error_pages -%>

Expand Down

0 comments on commit ba33bcc

Please sign in to comment.