Merge lp:~thomir-deactivatedaccount/core-image-watcher/trunk-use-uservice-utils into lp:core-image-watcher

Proposed by Thomi Richards
Status: Merged
Approved by: Thomi Richards
Approved revision: 13
Merged at revision: 13
Proposed branch: lp:~thomir-deactivatedaccount/core-image-watcher/trunk-use-uservice-utils
Merge into: lp:core-image-watcher
Diff against target: 87 lines (+8/-43)
2 files modified
core_image_watcher/__init__.py (+7/-43)
requirements.txt (+1/-0)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/core-image-watcher/trunk-use-uservice-utils
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+255001@code.launchpad.net

Commit message

Use uservice-utils.

Description of the change

Use uservice-utils.

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) :
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-31 16:23:22 +0000
3+++ core_image_watcher/__init__.py 2015-04-01 21:27:37 +0000
4@@ -20,14 +20,12 @@
5 import argparse
6 import configparser
7 import logging
8-import logging.handlers
9 import os
10 import subprocess
11 import time
12
13 import kombu
14-import logstash
15-
16+from uservice_utils.logging import configure_service_logging
17
18 from core_image_watcher import constants
19
20@@ -134,45 +132,6 @@
21 return body
22
23
24-def configure_logging(config):
25- root_logger = logging.getLogger()
26- root_logger.setLevel(logging.INFO)
27-
28- requests_logger = logging.getLogger('requests')
29- requests_logger.setLevel(logging.WARNING)
30-
31- # If there is no ./logs directory, fallback to stderr.
32- log_path = os.path.abspath(
33- os.path.join(__file__, '../../logs/core-image-watcher.log'))
34- log_dir = os.path.dirname(log_path)
35- if os.path.exists(log_dir):
36- handler = logging.handlers.TimedRotatingFileHandler(
37- log_path,
38- when='D',
39- interval=1
40- )
41- else:
42- print("'logs' directory '{}' does not exist, using stderr "
43- "for app log.".format(log_dir))
44- handler = logging.StreamHandler()
45-
46- handler.setFormatter(
47- logging.Formatter(
48- '%(asctime)s %(name)s %(levelname)s: %(message)s'
49- )
50- )
51- root_logger.addHandler(handler)
52-
53- if 'logstash' in config:
54- root_logger.addHandler(
55- logstash.LogstashHandler(
56- config['logstash']['host'],
57- int(config['logstash']['port']),
58- int(config['logstash']['version'])
59- )
60- )
61-
62-
63 def main():
64 parser = argparse.ArgumentParser(
65 description='Core image watcher ...')
66@@ -184,7 +143,12 @@
67 config = configparser.ConfigParser()
68 config.read(args.conf)
69
70- configure_logging(config)
71+ log_path = os.path.abspath(
72+ os.path.join(__file__, '../../logs/core-image-watcher.log'))
73+ configure_service_logging(
74+ log_path,
75+ config['logstash'] if 'logstash' in config else None
76+ )
77
78 amqp_uris = config.get('amqp', 'uris').split()
79 location = config.get('image', 'location')
80
81=== modified file 'requirements.txt'
82--- requirements.txt 2015-03-27 13:51:39 +0000
83+++ requirements.txt 2015-04-01 21:27:37 +0000
84@@ -1,2 +1,3 @@
85 kombu==3.0.24
86 python-logstash==0.4.2
87+uservice_utils==1.0.0

Subscribers

People subscribed via source and target branches

to all changes: