Merge lp:~brad-marshall/charms/trusty/thruk-master/add-debug-options into lp:~canonical-bootstack/charms/trusty/thruk-master/trunk

Proposed by Brad Marshall on 2015-08-31
Status: Merged
Merged at revision: 22
Proposed branch: lp:~brad-marshall/charms/trusty/thruk-master/add-debug-options
Merge into: lp:~canonical-bootstack/charms/trusty/thruk-master/trunk
Diff against target: 96 lines (+67/-0)
3 files modified
config.yaml (+21/-0)
hooks/services.py (+4/-0)
templates/log4perl.conf (+42/-0)
To merge this branch: bzr merge lp:~brad-marshall/charms/trusty/thruk-master/add-debug-options
Reviewer Review Type Date Requested Status
James Hebden (community) 2015-08-31 Approve on 2017-03-29
Review via email: mp+269595@code.launchpad.net

Description of the change

Add debug options, and configurable thruk logging paths.

To post a comment you must log in.
Peter Sabaini (peter-sabaini) wrote :

lgtm fwiw

James Hebden (ec0) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-05-05 04:47:26 +0000
3+++ config.yaml 2015-08-31 04:51:15 +0000
4@@ -34,4 +34,25 @@
5
6 If you're running multiple environments with the same services in them
7 this allows you to differentiate between them.
8+ log-path:
9+ default: "/var/log/thruk/thruk.log"
10+ type: string
11+ description: >
12+ The default log path.
13+ debug-log:
14+ default: false
15+ type: boolean
16+ description: >
17+ Enables debug logging for thruk.
18+ debug-log-path:
19+ default: "/var/log/thruk/debug.log"
20+ type: string
21+ description: >
22+ The default log path for debugging (if enabled).
23+ screen-log:
24+ default: false
25+ type: boolean
26+ description: >
27+ Enables debug logging to stderr for thruk - in the default case, this ends
28+ up in the apache error logs.
29
30
31=== modified file 'hooks/services.py'
32--- hooks/services.py 2015-06-24 00:14:14 +0000
33+++ hooks/services.py 2015-08-31 04:51:15 +0000
34@@ -23,11 +23,15 @@
35 # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
36 # helpers.MysqlRelation(),
37 thruk_helpers.ThrukMasterRelation(),
38+ helpers.RequiredConfig(),
39 ],
40 'data_ready': [
41 helpers.render_template(
42 source='thruk_local.conf',
43 target='/etc/thruk/thruk_local.conf'),
44+ helpers.render_template(
45+ source='log4perl.conf',
46+ target='/etc/thruk/log4perl.conf'),
47 actions.log_start,
48 actions.update_ppa,
49 actions.thruk_set_password,
50
51=== added file 'templates/log4perl.conf'
52--- templates/log4perl.conf 1970-01-01 00:00:00 +0000
53+++ templates/log4perl.conf 2015-08-31 04:51:15 +0000
54@@ -0,0 +1,42 @@
55+################################
56+## Logging Configuration
57+#
58+# see http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/Config.html
59+# for other configuration options
60+#
61+# normal logging, error messages and sent commands
62+#log4perl.logger=ALL, ThrukLog
63+
64+# enable this line to enable debug logging
65+# start "./script/thruk_server.pl -d" with -d to enable debugging
66+log4perl.logger=ALL, ThrukLog{%- if config['debug-log'] -%}, DebugLog{%- endif -%}{%- if config['screen-log'] -%}, Screen{%- endif %}
67+# you have to uncomment the logger definitions below too
68+
69+# normal log messages
70+log4perl.appender.ThrukLog=Log::Dispatch::File
71+log4perl.appender.ThrukLog.filename={{config['log-path']}}
72+log4perl.appender.ThrukLog.mode=append
73+log4perl.appender.ThrukLog.Threshold=INFO
74+log4perl.appender.ThrukLog.layout=Log::Log4perl::Layout::PatternLayout
75+log4perl.appender.ThrukLog.layout.ConversionPattern=[%d][%H][%p][%c] %m%n
76+
77+{%- if config['debug-log'] %}
78+## debug too
79+log4perl.appender.DebugLog=Log::Dispatch::File
80+log4perl.appender.DebugLog.filename={{config['debug-log-path']}}
81+log4perl.appender.DebugLog.mode=append
82+log4perl.appender.DebugLog.Threshold=DEBUG
83+log4perl.appender.DebugLog.layout=Log::Log4perl::Layout::PatternLayout
84+log4perl.appender.DebugLog.layout.ConversionPattern=[%d][%H][%p][%c] %m%n
85+{%- endif %}
86+
87+{%- if config['screen-log'] %}
88+## screen logger
89+#log4perl.logger = DEBUG, Screen
90+log4perl.appender.Screen = Log::Log4perl::Appender::Screen
91+log4perl.appender.Screen.stderr = 1
92+log4perl.appender.Screen.Threshold = DEBUG
93+log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout
94+log4perl.appender.Screen.layout.ConversionPattern = [%d][%H][%p][%c] %m%n
95+{%- endif %}
96+

Subscribers

People subscribed via source and target branches