Merge lp:~gholt/swift/logroutes into lp:~hudson-openstack/swift/trunk

Proposed by gholt
Status: Merged
Approved by: David Goetz
Approved revision: 213
Merged at revision: 214
Proposed branch: lp:~gholt/swift/logroutes
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 501 lines (+48/-44)
33 files modified
bin/swift-account-stats-logger (+1/-1)
bin/swift-drive-audit (+2/-1)
bin/swift-log-uploader (+1/-1)
swift/account/auditor.py (+1/-1)
swift/account/reaper.py (+1/-1)
swift/account/server.py (+1/-1)
swift/auth/server.py (+1/-1)
swift/common/daemon.py (+2/-2)
swift/common/db.py (+2/-2)
swift/common/db_replicator.py (+1/-1)
swift/common/middleware/catch_errors.py (+1/-5)
swift/common/middleware/cname_lookup.py (+1/-1)
swift/common/middleware/ratelimit.py (+1/-1)
swift/common/middleware/swauth.py (+1/-1)
swift/common/utils.py (+2/-0)
swift/common/wsgi.py (+1/-1)
swift/container/auditor.py (+1/-1)
swift/container/server.py (+1/-1)
swift/container/updater.py (+1/-1)
swift/obj/auditor.py (+1/-1)
swift/obj/replicator.py (+1/-1)
swift/obj/server.py (+1/-1)
swift/obj/updater.py (+1/-1)
swift/proxy/server.py (+1/-1)
swift/stats/access_processor.py (+1/-1)
swift/stats/account_stats.py (+2/-1)
swift/stats/log_processor.py (+2/-2)
swift/stats/log_uploader.py (+3/-2)
swift/stats/stats_processor.py (+1/-1)
test/unit/auth/test_server.py (+2/-2)
test/unit/common/test_daemon.py (+2/-2)
test/unit/common/test_utils.py (+5/-3)
test/unit/obj/test_auditor.py (+2/-1)
To merge this branch: bzr merge lp:~gholt/swift/logroutes
Reviewer Review Type Date Requested Status
clayg Approve
Review via email: mp+48388@code.launchpad.net

Commit message

logging: use routes to separate logging configurations

Description of the change

logging: use routes to separate logging configurations

Specifically, this fixes using different log_level settings even if the same log_name is used.

To post a comment you must log in.
lp:~gholt/swift/logroutes updated
209. By gholt

Merge from trunk

Revision history for this message
clayg (clay-gerrard) wrote :

Calling get_logger with a log_route kwarg instead of name as a positional argument isn't really the same thing. It may even have some side-effects that weren't intended?

e.g.
the drive-audit script logs as "swift" instead of "drive-audit"
swift-account-stats-logger logs as "log-processor-stats" instead of "swift-account-stats-logger" or just "account-stats"

I think things mostly sorta "work" because these conf dicts are coming out of readconf and run_wsgi which will both throw in a log_name key set to the section_name if there isn't something there already.

On the other hand... with this branch I can finally set a log_name for the auditors, updaters and replicators... so maybe it's a net gain?

Revision history for this message
gholt (gholt) wrote :

No, all that was intended. This separates the naming from the routing, then tries to get the naming defaults configured back to what they originally were, or what I thought was intended. I just missed some naming on items apparently.

I'll get the drive-audit name fixed. With the log processing stuff, I got lost pretty quick on what was intended to be named what and meant to tap you and John on that (but obviously forgot). Most everything in the system logs with no "swift-" prefix, but some of the log stuff was previously.

lp:~gholt/swift/logroutes updated
210. By gholt

Fix drive-audit's default log_name

Revision history for this message
gholt (gholt) wrote :

Fixed the drive-audit log name.

Maybe this comment doesn't belong here, but it's logging related so maybe it does, I dunno. :)

The log processing stuff is a bit confusing to me since it doesn't follow the model the rest of the code does. i.e. binary name ~= section name == default log name. It doesn't even seem to have consistency on it's own, really.

From trunk it seems to be:

The bin/swift-account-stats-logger uses the section log-processor-stats and logs as swift-account-stats-logger. Apparently this thing needs write access to my logs directory as well, but that's another discussion. :P

The bin/swift-log-stats-collector uses the section log-processor and logs as swift and log-stats-collector.

The bin/swift-log-uploader uses the section log-processor and logs as swift or just the plugin name (such as "access").

So, perhaps I can be forgiven for not knowing what to do with these during this logging refactor? I really don't want to mimic this behavior in this branch, unless that's really, really what's needed.

Revision history for this message
gholt (gholt) wrote :

Desnarkified by clayg and ready for re-review!

lp:~gholt/swift/logroutes updated
211. By gholt

Merge from ~clay-gerrard/swift/logroutes

Revision history for this message
clayg (clay-gerrard) wrote :

you are forgiven

review: Approve
lp:~gholt/swift/logroutes updated
212. By gholt

Merge from trunk

213. By gholt

PEP8 Fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/swift-account-stats-logger'
--- bin/swift-account-stats-logger 2011-01-04 23:34:43 +0000
+++ bin/swift-account-stats-logger 2011-02-10 23:12:47 +0000
@@ -23,4 +23,4 @@
23 # currently AccountStat only supports run_once23 # currently AccountStat only supports run_once
24 options['once'] = True24 options['once'] = True
25 run_daemon(AccountStat, conf_file, section_name='log-processor-stats',25 run_daemon(AccountStat, conf_file, section_name='log-processor-stats',
26 **options)26 log_name="account-stats", **options)
2727
=== modified file 'bin/swift-drive-audit'
--- bin/swift-drive-audit 2011-01-26 22:31:33 +0000
+++ bin/swift-drive-audit 2011-02-10 23:12:47 +0000
@@ -99,7 +99,8 @@
99 device_dir = conf.get('device_dir', '/srv/node')99 device_dir = conf.get('device_dir', '/srv/node')
100 minutes = int(conf.get('minutes', 60))100 minutes = int(conf.get('minutes', 60))
101 error_limit = int(conf.get('error_limit', 1))101 error_limit = int(conf.get('error_limit', 1))
102 logger = get_logger(conf, 'drive-audit')102 conf['log_name'] = conf.get('log_name', 'drive-audit')
103 logger = get_logger(conf, log_route='drive-audit')
103 devices = get_devices(device_dir, logger)104 devices = get_devices(device_dir, logger)
104 logger.debug("Devices found: %s" % str(devices))105 logger.debug("Devices found: %s" % str(devices))
105 if not devices:106 if not devices:
106107
=== modified file 'bin/swift-log-uploader'
--- bin/swift-log-uploader 2011-01-04 23:34:43 +0000
+++ bin/swift-log-uploader 2011-02-10 23:12:47 +0000
@@ -34,7 +34,7 @@
34 uploader_conf.update(plugin_conf)34 uploader_conf.update(plugin_conf)
3535
36 # pre-configure logger36 # pre-configure logger
37 logger = utils.get_logger(uploader_conf, plugin,37 logger = utils.get_logger(uploader_conf, log_route='log-uploader',
38 log_to_console=options.get('verbose', False))38 log_to_console=options.get('verbose', False))
39 # currently LogUploader only supports run_once39 # currently LogUploader only supports run_once
40 options['once'] = True40 options['once'] = True
4141
=== modified file 'swift/account/auditor.py'
--- swift/account/auditor.py 2011-01-04 23:34:43 +0000
+++ swift/account/auditor.py 2011-02-10 23:12:47 +0000
@@ -28,7 +28,7 @@
2828
29 def __init__(self, conf):29 def __init__(self, conf):
30 self.conf = conf30 self.conf = conf
31 self.logger = get_logger(conf, 'account-auditor')31 self.logger = get_logger(conf, log_route='account-auditor')
32 self.devices = conf.get('devices', '/srv/node')32 self.devices = conf.get('devices', '/srv/node')
33 self.mount_check = conf.get('mount_check', 'true').lower() in \33 self.mount_check = conf.get('mount_check', 'true').lower() in \
34 ('true', 't', '1', 'on', 'yes', 'y')34 ('true', 't', '1', 'on', 'yes', 'y')
3535
=== modified file 'swift/account/reaper.py'
--- swift/account/reaper.py 2011-01-19 23:21:57 +0000
+++ swift/account/reaper.py 2011-02-10 23:12:47 +0000
@@ -53,7 +53,7 @@
5353
54 def __init__(self, conf):54 def __init__(self, conf):
55 self.conf = conf55 self.conf = conf
56 self.logger = get_logger(conf)56 self.logger = get_logger(conf, log_route='account-reaper')
57 self.devices = conf.get('devices', '/srv/node')57 self.devices = conf.get('devices', '/srv/node')
58 self.mount_check = conf.get('mount_check', 'true').lower() in \58 self.mount_check = conf.get('mount_check', 'true').lower() in \
59 ('true', 't', '1', 'on', 'yes', 'y')59 ('true', 't', '1', 'on', 'yes', 'y')
6060
=== modified file 'swift/account/server.py'
--- swift/account/server.py 2011-01-29 19:26:06 +0000
+++ swift/account/server.py 2011-02-10 23:12:47 +0000
@@ -42,7 +42,7 @@
42 """WSGI controller for the account server."""42 """WSGI controller for the account server."""
4343
44 def __init__(self, conf):44 def __init__(self, conf):
45 self.logger = get_logger(conf)45 self.logger = get_logger(conf, log_route='account-server')
46 self.root = conf.get('devices', '/srv/node')46 self.root = conf.get('devices', '/srv/node')
47 self.mount_check = conf.get('mount_check', 'true').lower() in \47 self.mount_check = conf.get('mount_check', 'true').lower() in \
48 ('true', 't', '1', 'on', 'yes', 'y')48 ('true', 't', '1', 'on', 'yes', 'y')
4949
=== modified file 'swift/auth/server.py'
--- swift/auth/server.py 2011-01-26 22:38:13 +0000
+++ swift/auth/server.py 2011-02-10 23:12:47 +0000
@@ -90,7 +90,7 @@
90 """90 """
9191
92 def __init__(self, conf):92 def __init__(self, conf):
93 self.logger = get_logger(conf)93 self.logger = get_logger(conf, log_route='auth-server')
94 self.super_admin_key = conf.get('super_admin_key')94 self.super_admin_key = conf.get('super_admin_key')
95 if not self.super_admin_key:95 if not self.super_admin_key:
96 msg = _('No super_admin_key set in conf file! Exiting.')96 msg = _('No super_admin_key set in conf file! Exiting.')
9797
=== modified file 'swift/common/daemon.py'
--- swift/common/daemon.py 2011-01-04 23:34:43 +0000
+++ swift/common/daemon.py 2011-02-10 23:12:47 +0000
@@ -26,7 +26,7 @@
2626
27 def __init__(self, conf):27 def __init__(self, conf):
28 self.conf = conf28 self.conf = conf
29 self.logger = utils.get_logger(conf, 'swift-daemon')29 self.logger = utils.get_logger(conf, log_route='daemon')
3030
31 def run_once(self):31 def run_once(self):
32 """Override this to run the script once"""32 """Override this to run the script once"""
@@ -84,7 +84,7 @@
84 logger = kwargs.pop('logger')84 logger = kwargs.pop('logger')
85 else:85 else:
86 logger = utils.get_logger(conf, conf.get('log_name', section_name),86 logger = utils.get_logger(conf, conf.get('log_name', section_name),
87 log_to_console=kwargs.pop('verbose', False))87 log_to_console=kwargs.pop('verbose', False), log_route=section_name)
88 try:88 try:
89 klass(conf).run(once=once, **kwargs)89 klass(conf).run(once=once, **kwargs)
90 except KeyboardInterrupt:90 except KeyboardInterrupt:
9191
=== modified file 'swift/common/db.py'
--- swift/common/db.py 2011-02-04 19:50:30 +0000
+++ swift/common/db.py 2011-02-10 23:12:47 +0000
@@ -287,7 +287,7 @@
287 self.conn = None287 self.conn = None
288 orig_isolation_level = conn.isolation_level288 orig_isolation_level = conn.isolation_level
289 conn.isolation_level = None289 conn.isolation_level = None
290 conn.execute('PRAGMA journal_mode = DELETE') # remove any journal files290 conn.execute('PRAGMA journal_mode = DELETE') # remove journal files
291 conn.execute('BEGIN IMMEDIATE')291 conn.execute('BEGIN IMMEDIATE')
292 try:292 try:
293 yield True293 yield True
@@ -295,7 +295,7 @@
295 pass295 pass
296 try:296 try:
297 conn.execute('ROLLBACK')297 conn.execute('ROLLBACK')
298 conn.execute('PRAGMA journal_mode = WAL') # back to WAL mode298 conn.execute('PRAGMA journal_mode = WAL') # back to WAL mode
299 conn.isolation_level = orig_isolation_level299 conn.isolation_level = orig_isolation_level
300 self.conn = conn300 self.conn = conn
301 except Exception:301 except Exception:
302302
=== modified file 'swift/common/db_replicator.py'
--- swift/common/db_replicator.py 2011-01-29 19:26:06 +0000
+++ swift/common/db_replicator.py 2011-02-10 23:12:47 +0000
@@ -92,7 +92,7 @@
9292
93 def __init__(self, conf):93 def __init__(self, conf):
94 self.conf = conf94 self.conf = conf
95 self.logger = get_logger(conf)95 self.logger = get_logger(conf, log_route='replicator')
96 self.root = conf.get('devices', '/srv/node')96 self.root = conf.get('devices', '/srv/node')
97 self.mount_check = conf.get('mount_check', 'true').lower() in \97 self.mount_check = conf.get('mount_check', 'true').lower() in \
98 ('true', 't', '1', 'on', 'yes', 'y')98 ('true', 't', '1', 'on', 'yes', 'y')
9999
=== modified file 'swift/common/middleware/catch_errors.py'
--- swift/common/middleware/catch_errors.py 2011-01-07 21:17:29 +0000
+++ swift/common/middleware/catch_errors.py 2011-02-10 23:12:47 +0000
@@ -26,11 +26,7 @@
2626
27 def __init__(self, app, conf):27 def __init__(self, app, conf):
28 self.app = app28 self.app = app
29 # if the application already has a logger we should use that one29 self.logger = get_logger(conf, log_route='catch-errors')
30 self.logger = getattr(app, 'logger', None)
31 if not self.logger:
32 # and only call get_logger if we have to
33 self.logger = get_logger(conf)
3430
35 def __call__(self, env, start_response):31 def __call__(self, env, start_response):
36 try:32 try:
3733
=== modified file 'swift/common/middleware/cname_lookup.py'
--- swift/common/middleware/cname_lookup.py 2011-01-20 20:15:05 +0000
+++ swift/common/middleware/cname_lookup.py 2011-02-10 23:12:47 +0000
@@ -53,7 +53,7 @@
53 self.storage_domain = '.' + self.storage_domain53 self.storage_domain = '.' + self.storage_domain
54 self.lookup_depth = int(conf.get('lookup_depth', '1'))54 self.lookup_depth = int(conf.get('lookup_depth', '1'))
55 self.memcache = None55 self.memcache = None
56 self.logger = get_logger(conf)56 self.logger = get_logger(conf, log_route='cname-lookup')
5757
58 def __call__(self, env, start_response):58 def __call__(self, env, start_response):
59 if not self.storage_domain:59 if not self.storage_domain:
6060
=== modified file 'swift/common/middleware/ratelimit.py'
--- swift/common/middleware/ratelimit.py 2011-01-22 00:28:58 +0000
+++ swift/common/middleware/ratelimit.py 2011-02-10 23:12:47 +0000
@@ -39,7 +39,7 @@
39 if logger:39 if logger:
40 self.logger = logger40 self.logger = logger
41 else:41 else:
42 self.logger = get_logger(conf)42 self.logger = get_logger(conf, log_route='ratelimit')
43 self.account_ratelimit = float(conf.get('account_ratelimit', 0))43 self.account_ratelimit = float(conf.get('account_ratelimit', 0))
44 self.max_sleep_time_seconds = \44 self.max_sleep_time_seconds = \
45 float(conf.get('max_sleep_time_seconds', 60))45 float(conf.get('max_sleep_time_seconds', 60))
4646
=== modified file 'swift/common/middleware/swauth.py'
--- swift/common/middleware/swauth.py 2011-02-02 18:23:01 +0000
+++ swift/common/middleware/swauth.py 2011-02-10 23:12:47 +0000
@@ -51,7 +51,7 @@
51 def __init__(self, app, conf):51 def __init__(self, app, conf):
52 self.app = app52 self.app = app
53 self.conf = conf53 self.conf = conf
54 self.logger = get_logger(conf)54 self.logger = get_logger(conf, log_route='swauth')
55 self.log_headers = conf.get('log_headers') == 'True'55 self.log_headers = conf.get('log_headers') == 'True'
56 self.reseller_prefix = conf.get('reseller_prefix', 'AUTH').strip()56 self.reseller_prefix = conf.get('reseller_prefix', 'AUTH').strip()
57 if self.reseller_prefix and self.reseller_prefix[-1] != '_':57 if self.reseller_prefix and self.reseller_prefix[-1] != '_':
5858
=== modified file 'swift/common/utils.py'
--- swift/common/utils.py 2011-02-10 21:23:59 +0000
+++ swift/common/utils.py 2011-02-10 23:12:47 +0000
@@ -390,6 +390,8 @@
390 :param conf: Configuration dict to read settings from390 :param conf: Configuration dict to read settings from
391 :param name: Name of the logger391 :param name: Name of the logger
392 :param log_to_console: Add handler which writes to console on stderr392 :param log_to_console: Add handler which writes to console on stderr
393 :param log_route: Route for the logging, not emitted to the log, just used
394 to separate logging configurations
393 :param fmt: Override log format395 :param fmt: Override log format
394 """396 """
395 if not conf:397 if not conf:
396398
=== modified file 'swift/common/wsgi.py'
--- swift/common/wsgi.py 2011-02-05 21:38:49 +0000
+++ swift/common/wsgi.py 2011-02-10 23:12:47 +0000
@@ -113,7 +113,7 @@
113 logger = kwargs.pop('logger')113 logger = kwargs.pop('logger')
114 else:114 else:
115 logger = get_logger(conf, log_name,115 logger = get_logger(conf, log_name,
116 log_to_console=kwargs.pop('verbose', False))116 log_to_console=kwargs.pop('verbose', False), log_route='wsgi')
117117
118 # redirect errors to logger and close stdio118 # redirect errors to logger and close stdio
119 capture_stdio(logger)119 capture_stdio(logger)
120120
=== modified file 'swift/container/auditor.py'
--- swift/container/auditor.py 2011-01-04 23:34:43 +0000
+++ swift/container/auditor.py 2011-02-10 23:12:47 +0000
@@ -28,7 +28,7 @@
2828
29 def __init__(self, conf):29 def __init__(self, conf):
30 self.conf = conf30 self.conf = conf
31 self.logger = get_logger(conf, 'container-auditor')31 self.logger = get_logger(conf, log_route='container-auditor')
32 self.devices = conf.get('devices', '/srv/node')32 self.devices = conf.get('devices', '/srv/node')
33 self.mount_check = conf.get('mount_check', 'true').lower() in \33 self.mount_check = conf.get('mount_check', 'true').lower() in \
34 ('true', 't', '1', 'on', 'yes', 'y')34 ('true', 't', '1', 'on', 'yes', 'y')
3535
=== modified file 'swift/container/server.py'
--- swift/container/server.py 2011-01-29 19:26:06 +0000
+++ swift/container/server.py 2011-02-10 23:12:47 +0000
@@ -49,7 +49,7 @@
49 save_headers = ['x-container-read', 'x-container-write']49 save_headers = ['x-container-read', 'x-container-write']
5050
51 def __init__(self, conf):51 def __init__(self, conf):
52 self.logger = get_logger(conf)52 self.logger = get_logger(conf, log_route='container-server')
53 self.root = conf.get('devices', '/srv/node/')53 self.root = conf.get('devices', '/srv/node/')
54 self.mount_check = conf.get('mount_check', 'true').lower() in \54 self.mount_check = conf.get('mount_check', 'true').lower() in \
55 ('true', 't', '1', 'on', 'yes', 'y')55 ('true', 't', '1', 'on', 'yes', 'y')
5656
=== modified file 'swift/container/updater.py'
--- swift/container/updater.py 2011-01-26 22:38:13 +0000
+++ swift/container/updater.py 2011-02-10 23:12:47 +0000
@@ -37,7 +37,7 @@
3737
38 def __init__(self, conf):38 def __init__(self, conf):
39 self.conf = conf39 self.conf = conf
40 self.logger = get_logger(conf, 'container-updater')40 self.logger = get_logger(conf, log_route='container-updater')
41 self.devices = conf.get('devices', '/srv/node')41 self.devices = conf.get('devices', '/srv/node')
42 self.mount_check = conf.get('mount_check', 'true').lower() in \42 self.mount_check = conf.get('mount_check', 'true').lower() in \
43 ('true', 't', '1', 'on', 'yes', 'y')43 ('true', 't', '1', 'on', 'yes', 'y')
4444
=== modified file 'swift/obj/auditor.py'
--- swift/obj/auditor.py 2011-01-21 01:05:44 +0000
+++ swift/obj/auditor.py 2011-02-10 23:12:47 +0000
@@ -31,7 +31,7 @@
3131
32 def __init__(self, conf):32 def __init__(self, conf):
33 self.conf = conf33 self.conf = conf
34 self.logger = get_logger(conf, 'object-auditor')34 self.logger = get_logger(conf, log_route='object-auditor')
35 self.devices = conf.get('devices', '/srv/node')35 self.devices = conf.get('devices', '/srv/node')
36 self.mount_check = conf.get('mount_check', 'true').lower() in \36 self.mount_check = conf.get('mount_check', 'true').lower() in \
37 ('true', 't', '1', 'on', 'yes', 'y')37 ('true', 't', '1', 'on', 'yes', 'y')
3838
=== modified file 'swift/obj/replicator.py'
--- swift/obj/replicator.py 2011-01-27 22:42:36 +0000
+++ swift/obj/replicator.py 2011-02-10 23:12:47 +0000
@@ -207,7 +207,7 @@
207 :param logger: logging object207 :param logger: logging object
208 """208 """
209 self.conf = conf209 self.conf = conf
210 self.logger = get_logger(conf, 'object-replicator')210 self.logger = get_logger(conf, log_route='object-replicator')
211 self.devices_dir = conf.get('devices', '/srv/node')211 self.devices_dir = conf.get('devices', '/srv/node')
212 self.mount_check = conf.get('mount_check', 'true').lower() in \212 self.mount_check = conf.get('mount_check', 'true').lower() in \
213 ('true', 't', '1', 'on', 'yes', 'y')213 ('true', 't', '1', 'on', 'yes', 'y')
214214
=== modified file 'swift/obj/server.py'
--- swift/obj/server.py 2011-01-26 22:38:13 +0000
+++ swift/obj/server.py 2011-02-10 23:12:47 +0000
@@ -266,7 +266,7 @@
266 <source-dir>/etc/object-server.conf-sample or266 <source-dir>/etc/object-server.conf-sample or
267 /etc/swift/object-server.conf-sample.267 /etc/swift/object-server.conf-sample.
268 """268 """
269 self.logger = get_logger(conf)269 self.logger = get_logger(conf, log_route='object-server')
270 self.devices = conf.get('devices', '/srv/node/')270 self.devices = conf.get('devices', '/srv/node/')
271 self.mount_check = conf.get('mount_check', 'true').lower() in \271 self.mount_check = conf.get('mount_check', 'true').lower() in \
272 ('true', 't', '1', 'on', 'yes', 'y')272 ('true', 't', '1', 'on', 'yes', 'y')
273273
=== modified file 'swift/obj/updater.py'
--- swift/obj/updater.py 2011-01-26 22:31:33 +0000
+++ swift/obj/updater.py 2011-02-10 23:12:47 +0000
@@ -35,7 +35,7 @@
3535
36 def __init__(self, conf):36 def __init__(self, conf):
37 self.conf = conf37 self.conf = conf
38 self.logger = get_logger(conf, 'object-updater')38 self.logger = get_logger(conf, log_route='object-updater')
39 self.devices = conf.get('devices', '/srv/node')39 self.devices = conf.get('devices', '/srv/node')
40 self.mount_check = conf.get('mount_check', 'true').lower() in \40 self.mount_check = conf.get('mount_check', 'true').lower() in \
41 ('true', 't', '1', 'on', 'yes', 'y')41 ('true', 't', '1', 'on', 'yes', 'y')
4242
=== modified file 'swift/proxy/server.py'
--- swift/proxy/server.py 2011-02-10 20:59:52 +0000
+++ swift/proxy/server.py 2011-02-10 23:12:47 +0000
@@ -1609,7 +1609,7 @@
1609 if conf is None:1609 if conf is None:
1610 conf = {}1610 conf = {}
1611 if logger is None:1611 if logger is None:
1612 self.logger = get_logger(conf)1612 self.logger = get_logger(conf, log_route='proxy-server')
1613 access_log_conf = {}1613 access_log_conf = {}
1614 for key in ('log_facility', 'log_name', 'log_level'):1614 for key in ('log_facility', 'log_name', 'log_level'):
1615 value = conf.get('access_' + key, conf.get(key, None))1615 value = conf.get('access_' + key, conf.get(key, None))
16161616
=== modified file 'swift/stats/access_processor.py'
--- swift/stats/access_processor.py 2011-01-17 17:07:58 +0000
+++ swift/stats/access_processor.py 2011-02-10 23:12:47 +0000
@@ -34,7 +34,7 @@
34 conf.get('service_ips', '').split(',')\34 conf.get('service_ips', '').split(',')\
35 if x.strip()]35 if x.strip()]
36 self.warn_percent = float(conf.get('warn_percent', '0.8'))36 self.warn_percent = float(conf.get('warn_percent', '0.8'))
37 self.logger = get_logger(conf)37 self.logger = get_logger(conf, log_route='access-processor')
3838
39 def log_line_parser(self, raw_log):39 def log_line_parser(self, raw_log):
40 '''given a raw access log line, return a dict of the good parts'''40 '''given a raw access log line, return a dict of the good parts'''
4141
=== modified file 'swift/stats/account_stats.py'
--- swift/stats/account_stats.py 2011-01-30 14:59:35 +0000
+++ swift/stats/account_stats.py 2011-02-10 23:12:47 +0000
@@ -48,7 +48,8 @@
48 self.devices = server_conf.get('devices', '/srv/node')48 self.devices = server_conf.get('devices', '/srv/node')
49 self.mount_check = server_conf.get('mount_check', 'true').lower() in \49 self.mount_check = server_conf.get('mount_check', 'true').lower() in \
50 ('true', 't', '1', 'on', 'yes', 'y')50 ('true', 't', '1', 'on', 'yes', 'y')
51 self.logger = get_logger(stats_conf, 'swift-account-stats-logger')51 self.logger = \
52 get_logger(stats_conf, log_route='account-stats')
5253
53 def run_once(self):54 def run_once(self):
54 self.logger.info(_("Gathering account stats"))55 self.logger.info(_("Gathering account stats"))
5556
=== modified file 'swift/stats/log_processor.py'
--- swift/stats/log_processor.py 2011-01-26 22:38:13 +0000
+++ swift/stats/log_processor.py 2011-02-10 23:12:47 +0000
@@ -40,7 +40,7 @@
4040
41 def __init__(self, conf, logger):41 def __init__(self, conf, logger):
42 if isinstance(logger, tuple):42 if isinstance(logger, tuple):
43 self.logger = get_logger(*logger)43 self.logger = get_logger(*logger, log_route='log-processor')
44 else:44 else:
45 self.logger = logger45 self.logger = logger
4646
@@ -226,7 +226,7 @@
226 c = conf.get('log-processor')226 c = conf.get('log-processor')
227 super(LogProcessorDaemon, self).__init__(c)227 super(LogProcessorDaemon, self).__init__(c)
228 self.total_conf = conf228 self.total_conf = conf
229 self.logger = get_logger(c)229 self.logger = get_logger(c, log_route='log-processor')
230 self.log_processor = LogProcessor(conf, self.logger)230 self.log_processor = LogProcessor(conf, self.logger)
231 self.lookback_hours = int(c.get('lookback_hours', '120'))231 self.lookback_hours = int(c.get('lookback_hours', '120'))
232 self.lookback_window = int(c.get('lookback_window',232 self.lookback_window = int(c.get('lookback_window',
233233
=== modified file 'swift/stats/log_uploader.py'
--- swift/stats/log_uploader.py 2011-01-14 08:45:39 +0000
+++ swift/stats/log_uploader.py 2011-02-10 23:12:47 +0000
@@ -64,8 +64,9 @@
64 self.container_name = container_name64 self.container_name = container_name
65 self.filename_format = source_filename_format65 self.filename_format = source_filename_format
66 self.internal_proxy = InternalProxy(proxy_server_conf)66 self.internal_proxy = InternalProxy(proxy_server_conf)
67 log_name = 'swift-log-uploader-%s' % plugin_name67 log_name = '%s-log-uploader' % plugin_name
68 self.logger = utils.get_logger(uploader_conf, plugin_name)68 self.logger = utils.get_logger(uploader_conf, log_name,
69 log_route=plugin_name)
6970
70 def run_once(self):71 def run_once(self):
71 self.logger.info(_("Uploading logs"))72 self.logger.info(_("Uploading logs"))
7273
=== modified file 'swift/stats/stats_processor.py'
--- swift/stats/stats_processor.py 2011-01-19 23:21:57 +0000
+++ swift/stats/stats_processor.py 2011-02-10 23:12:47 +0000
@@ -20,7 +20,7 @@
20 """Transform account storage stat logs"""20 """Transform account storage stat logs"""
2121
22 def __init__(self, conf):22 def __init__(self, conf):
23 self.logger = get_logger(conf)23 self.logger = get_logger(conf, log_route='stats-processor')
2424
25 def process(self, obj_stream, data_object_account, data_object_container,25 def process(self, obj_stream, data_object_account, data_object_container,
26 data_object_name):26 data_object_name):
2727
=== modified file 'test/unit/auth/test_server.py'
--- test/unit/auth/test_server.py 2011-01-19 23:21:57 +0000
+++ test/unit/auth/test_server.py 2011-02-10 23:12:47 +0000
@@ -456,7 +456,7 @@
456 def test_basic_logging(self):456 def test_basic_logging(self):
457 log = StringIO()457 log = StringIO()
458 log_handler = StreamHandler(log)458 log_handler = StreamHandler(log)
459 logger = get_logger(self.conf, 'auth')459 logger = get_logger(self.conf, 'auth-server', log_route='auth-server')
460 logger.logger.addHandler(log_handler)460 logger.logger.addHandler(log_handler)
461 try:461 try:
462 auth_server.http_connect = fake_http_connect(201)462 auth_server.http_connect = fake_http_connect(201)
@@ -534,7 +534,7 @@
534 orig_Request = auth_server.Request534 orig_Request = auth_server.Request
535 log = StringIO()535 log = StringIO()
536 log_handler = StreamHandler(log)536 log_handler = StreamHandler(log)
537 logger = get_logger(self.conf, 'auth')537 logger = get_logger(self.conf, 'auth-server', log_route='auth-server')
538 logger.logger.addHandler(log_handler)538 logger.logger.addHandler(log_handler)
539 try:539 try:
540 auth_server.Request = request_causing_exception540 auth_server.Request = request_causing_exception
541541
=== modified file 'test/unit/common/test_daemon.py'
--- test/unit/common/test_daemon.py 2011-02-02 17:38:17 +0000
+++ test/unit/common/test_daemon.py 2011-02-10 23:12:47 +0000
@@ -28,7 +28,7 @@
2828
29 def __init__(self, conf):29 def __init__(self, conf):
30 self.conf = conf30 self.conf = conf
31 self.logger = utils.get_logger(None, 'server')31 self.logger = utils.get_logger(None, 'server', log_route='server')
32 MyDaemon.forever_called = False32 MyDaemon.forever_called = False
33 MyDaemon.once_called = False33 MyDaemon.once_called = False
3434
@@ -99,7 +99,7 @@
99 sio = StringIO()99 sio = StringIO()
100 logger = logging.getLogger('server')100 logger = logging.getLogger('server')
101 logger.addHandler(logging.StreamHandler(sio))101 logger.addHandler(logging.StreamHandler(sio))
102 logger = utils.get_logger(None, 'server')102 logger = utils.get_logger(None, 'server', log_route='server')
103 daemon.run_daemon(MyDaemon, conf_file, logger=logger)103 daemon.run_daemon(MyDaemon, conf_file, logger=logger)
104 self.assert_('user quit' in sio.getvalue().lower())104 self.assert_('user quit' in sio.getvalue().lower())
105105
106106
=== modified file 'test/unit/common/test_utils.py'
--- test/unit/common/test_utils.py 2011-02-10 20:59:52 +0000
+++ test/unit/common/test_utils.py 2011-02-10 23:12:47 +0000
@@ -303,17 +303,19 @@
303 sio = StringIO()303 sio = StringIO()
304 logger = logging.getLogger('server')304 logger = logging.getLogger('server')
305 logger.addHandler(logging.StreamHandler(sio))305 logger.addHandler(logging.StreamHandler(sio))
306 logger = utils.get_logger(None, 'server')306 logger = utils.get_logger(None, 'server', log_route='server')
307 logger.warn('test1')307 logger.warn('test1')
308 self.assertEquals(sio.getvalue(), 'test1\n')308 self.assertEquals(sio.getvalue(), 'test1\n')
309 logger.debug('test2')309 logger.debug('test2')
310 self.assertEquals(sio.getvalue(), 'test1\n')310 self.assertEquals(sio.getvalue(), 'test1\n')
311 logger = utils.get_logger({'log_level': 'DEBUG'}, 'server')311 logger = utils.get_logger({'log_level': 'DEBUG'}, 'server',
312 log_route='server')
312 logger.debug('test3')313 logger.debug('test3')
313 self.assertEquals(sio.getvalue(), 'test1\ntest3\n')314 self.assertEquals(sio.getvalue(), 'test1\ntest3\n')
314 # Doesn't really test that the log facility is truly being used all the315 # Doesn't really test that the log facility is truly being used all the
315 # way to syslog; but exercises the code.316 # way to syslog; but exercises the code.
316 logger = utils.get_logger({'log_facility': 'LOG_LOCAL3'}, 'server')317 logger = utils.get_logger({'log_facility': 'LOG_LOCAL3'}, 'server',
318 log_route='server')
317 logger.warn('test4')319 logger.warn('test4')
318 self.assertEquals(sio.getvalue(),320 self.assertEquals(sio.getvalue(),
319 'test1\ntest3\ntest4\n')321 'test1\ntest3\ntest4\n')
320322
=== modified file 'test/unit/obj/test_auditor.py'
--- test/unit/obj/test_auditor.py 2011-01-25 01:12:38 +0000
+++ test/unit/obj/test_auditor.py 2011-02-10 23:12:47 +0000
@@ -14,7 +14,7 @@
14# limitations under the License.14# limitations under the License.
1515
16# TODO: Tests16# TODO: Tests
17from test import unit as _setup_mocks17from test import unit
18import unittest18import unittest
19import tempfile19import tempfile
20import os20import os
@@ -57,6 +57,7 @@
5757
58 def tearDown(self):58 def tearDown(self):
59 rmtree(os.path.dirname(self.testdir), ignore_errors=1)59 rmtree(os.path.dirname(self.testdir), ignore_errors=1)
60 unit.xattr_data = {}
6061
61 def test_object_audit_extra_data(self):62 def test_object_audit_extra_data(self):
62 self.auditor = auditor.ObjectAuditor(self.conf)63 self.auditor = auditor.ObjectAuditor(self.conf)