Skip to content

Commit 19c6024

Browse files
author
Shiva Poudel
committed
Merge pull request voxpupuli#275 from xaniasd/master
add configurable log level for gunicorn and unit tests
2 parents 0d08d4e + 6c301da commit 19c6024

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

manifests/gunicorn.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
$access_log_format = false,
8181
$accesslog = false,
8282
$errorlog = false,
83+
$log_level = 'error',
8384
$template = 'python/gunicorn.erb',
8485
) {
8586

@@ -88,6 +89,8 @@
8889
fail('python::gunicorn: dir parameter must not be empty')
8990
}
9091

92+
validate_re($log_level, 'debug|info|warning|error|critical', "Invalid \$log_level value ${log_level}")
93+
9194
file { "/etc/gunicorn.d/${name}":
9295
ensure => $ensure,
9396
mode => '0644',

spec/defines/gunicorn_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
3+
describe 'python::gunicorn', :type => :define do
4+
let(:title) { 'test-app' }
5+
context 'on Debian OS' do
6+
let :facts do
7+
{
8+
:id => 'root',
9+
:kernel => 'Linux',
10+
:lsbdistcodename => 'squeeze',
11+
:osfamily => 'Debian',
12+
:operatingsystem => 'Debian',
13+
:operatingsystemrelease => '6',
14+
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
15+
:concat_basedir => '/dne',
16+
}
17+
end
18+
19+
describe 'test-app with default parameter values' do
20+
context 'configures test app with default parameter values' do
21+
let(:params) { { :dir => '/srv/testapp' } }
22+
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--log-level=error/) }
23+
end
24+
25+
context 'test-app with custom log level' do
26+
let(:params) { { :dir => '/srv/testapp', :log_level => 'info' } }
27+
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(/--log-level=info/) }
28+
end
29+
end
30+
end
31+
end

templates/gunicorn.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ CONFIG = {
4242
<% if @errorlog -%>
4343
'--error-logfile=<%= @errorlog %>',
4444
<% end -%>
45+
<% if @log_level %>
46+
'--log-level=<%= @log_level %>',
47+
<% end -%>
4548
<% if @mode != 'django' -%>
4649
'<%= @appmodule %>',
4750
<% end -%>

0 commit comments

Comments
 (0)