Merge lp:~thomir-deactivatedaccount/core-image-watcher/trunk-rotate-logs into lp:core-image-watcher

Proposed by Thomi Richards
Status: Merged
Approved by: Celso Providelo
Approved revision: 6
Merged at revision: 6
Proposed branch: lp:~thomir-deactivatedaccount/core-image-watcher/trunk-rotate-logs
Merge into: lp:core-image-watcher
Diff against target: 24 lines (+6/-1)
1 file modified
core_image_watcher/__init__.py (+6/-1)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/core-image-watcher/trunk-rotate-logs
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+254344@code.launchpad.net

Commit message

Use a rotating log file handler.

Description of the change

Use a rotating log file handler.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

I love simple things!

Thanks for incorporating it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'core_image_watcher/__init__.py'
2--- core_image_watcher/__init__.py 2015-03-26 20:44:05 +0000
3+++ core_image_watcher/__init__.py 2015-03-27 04:21:49 +0000
4@@ -20,6 +20,7 @@
5 import argparse
6 import configparser
7 import logging
8+import logging.handlers
9 import os
10 import subprocess
11 import time
12@@ -129,7 +130,11 @@
13 os.path.join(__file__, '../../logs/core-image-watcher.log'))
14 log_dir = os.path.dirname(log_path)
15 if os.path.exists(log_dir):
16- handler = logging.FileHandler(log_path)
17+ handler = logging.handlers.TimedRotatingFileHandler(
18+ log_path,
19+ when='D',
20+ interval=1
21+ )
22 else:
23 print("'logs' directory '{}' does not exist, using stderr "
24 "for app log.".format(log_dir))

Subscribers

People subscribed via source and target branches

to all changes: