Merge lp:~javier.collado/utah/bug1088376 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Max Brustkern
Approved revision: 883
Merged at revision: 889
Proposed branch: lp:~javier.collado/utah/bug1088376
Merge into: lp:utah
Diff against target: 77 lines (+24/-3)
3 files modified
debian/changelog (+3/-0)
utah/config.py (+5/-0)
utah/run.py (+16/-3)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1088376
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Andy Doan (community) Approve
Review via email: mp+161925@code.launchpad.net

Description of the change

This branch uses logging.handlers.TimedRotatingFileHandler for log server files
and grabs the values for the log rotation from the configuration file.

The default values are:
- rotate files every week on Monday
- keep 10 backup files at the most

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) :
review: Approve
Revision history for this message
Max Brustkern (nuclearbob) wrote :

Is there any way to also handle things like yaml files and preseeds, or should we setup a separate logrotate script for those?

Revision history for this message
Javier Collado (javier.collado) wrote :

@Max

I guess we could reuse the backup count logic in a logging handler to implement that behavior for yaml files and preseeds. However, that would look like a hack. Probably best way to address that would be to have our own class to handle the backup count for files with the same given prefix.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Okay. I think we can come back to that later, and this is worth getting in in the meantime.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-05-01 17:37:58 +0000
3+++ debian/changelog 2013-05-01 19:18:29 +0000
4@@ -16,6 +16,9 @@
5 * Fixed help output to use just one runlist (LP: #1112597)
6 * Setup rc.local to use output passed via command line (LP: #1155615)
7
8+ [ Javier Collado ]
9+ * Rotate server log files based on time (LP: #1088376)
10+
11 -- Max Brustkern <max@canonical.com> Fri, 26 Apr 2013 13:58:25 -0400
12
13 utah (0.10ubuntu1) UNRELEASED; urgency=low
14
15=== modified file 'utah/config.py'
16--- utah/config.py 2013-04-04 14:55:25 +0000
17+++ utah/config.py 2013-05-01 19:18:29 +0000
18@@ -97,6 +97,11 @@
19 kernel=None,
20 # Default location of log directory
21 logpath=os.path.join('/', 'var', 'log', 'utah'),
22+ # Server files are rotated using logging.handlers.TimedRotatingLogHandler
23+ # with the parameters below
24+ logrotation_when='W0',
25+ logrotation_interval=1,
26+ logrotation_backupCount=10,
27 # Default machine ID
28 machineid=None,
29 # Default machine type
30
31=== modified file 'utah/run.py'
32--- utah/run.py 2013-04-19 19:27:58 +0000
33+++ utah/run.py 2013-05-01 19:18:29 +0000
34@@ -18,6 +18,7 @@
35
36 from argparse import ArgumentTypeError
37 import logging
38+from logging.handlers import TimedRotatingFileHandler
39 import os
40 import shutil
41 import signal
42@@ -449,7 +450,11 @@
43 logger.addHandler(console_handler)
44
45 # File logging
46- file_handler = logging.handlers.WatchedFileHandler(config.logfile)
47+ file_handler = \
48+ TimedRotatingFileHandler(config.logfile,
49+ when=config.logrotation_when,
50+ interval=config.logrotation_interval,
51+ utc=True)
52 file_handler.setFormatter(formatter)
53 file_handler.setLevel(config.fileloglevel)
54 logger.addHandler(file_handler)
55@@ -457,13 +462,21 @@
56 # Debug file logging
57 if config.debuglog is not None:
58 debug_file_handler = \
59- logging.handlers.WatchedFileHandler(config.debuglog)
60+ TimedRotatingFileHandler(config.debuglog,
61+ when=config.logrotation_when,
62+ interval=config.logrotation_interval,
63+ utc=True)
64 debug_file_handler.setFormatter(formatter)
65 debug_file_handler.setLevel(logging.DEBUG)
66 logger.addHandler(debug_file_handler)
67
68 # Configure ssh logging in a separate file
69- ssh_file_handler = logging.handlers.WatchedFileHandler(config.ssh_logfile)
70+ ssh_file_handler = \
71+ TimedRotatingFileHandler(config.ssh_logfile,
72+ when=config.logrotation_when,
73+ interval=config.logrotation_interval,
74+ utc=True)
75+
76 ssh_file_handler.setFormatter(formatter)
77 ssh_file_handler.setLevel(logging.DEBUG)
78

Subscribers

People subscribed via source and target branches