Merge lp:~mikemc/ubuntuone-client/log-monitor into lp:ubuntuone-client

Proposed by Mike McCracken
Status: Merged
Approved by: Roberto Alsina
Approved revision: 1297
Merged at revision: 1296
Proposed branch: lp:~mikemc/ubuntuone-client/log-monitor
Merge into: lp:ubuntuone-client
Diff against target: 52 lines (+13/-3)
1 file modified
ubuntuone/platform/filesystem_notifications/monitor/__init__.py (+13/-3)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-client/log-monitor
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+121507@code.launchpad.net

Commit message

- Log to syncdaemon log which monitor implementation is used. (LP: #1042336)

Description of the change

- Log to syncdaemon log which monitor implementation is used. (LP: #1042336)

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/platform/filesystem_notifications/monitor/__init__.py'
2--- ubuntuone/platform/filesystem_notifications/monitor/__init__.py 2012-08-01 14:25:58 +0000
3+++ ubuntuone/platform/filesystem_notifications/monitor/__init__.py 2012-08-27 21:57:20 +0000
4@@ -32,6 +32,8 @@
5
6 from twisted.internet import defer
7
8+from ubuntuone.syncdaemon.logger import root_logger as logger
9+
10 DEFAULT_MONITOR = 'default'
11
12
13@@ -70,6 +72,7 @@
14 DEFAULT_MONITOR: linux.FilesystemMonitor,
15 }
16
17+
18 # mantain old API
19 FilesystemMonitor = FILEMONITOR_IDS[DEFAULT_MONITOR]
20
21@@ -77,21 +80,28 @@
22 @defer.inlineCallbacks
23 def get_filemonitor_class(monitor_id=None):
24 """Return the class to be used."""
25+ logger.debug('File monitor ids for platform "%s" are "%s"', sys.platform,
26+ FILEMONITOR_IDS)
27+
28 if monitor_id is None:
29- # use default
30+ logger.debug('monitor_id is None, using default.')
31 monitor_id = 'default'
32
33 if monitor_id not in FILEMONITOR_IDS:
34- raise NoAvailableMonitorError(
35- 'No available monitor with id "%s"could be found.' % monitor_id)
36+ msg = 'No available monitor with id %r could be found.'
37+ raise NoAvailableMonitorError(msg % monitor_id)
38
39 # retrieve the correct class and assert it can be used
40 cls = FILEMONITOR_IDS[monitor_id]
41+ logger.debug('Checking availability of monitor class %ns', cls)
42 is_available = yield cls.is_available_monitor()
43
44 if is_available:
45+ logger.debug('Monitor is available, returning monitor with id "%s"',
46+ monitor_id)
47 defer.returnValue(cls)
48 elif not is_available and monitor_id != DEFAULT_MONITOR:
49+ logger.debug('Monitor is NOT available, returning default monitor.')
50 cls = yield get_filemonitor_class(DEFAULT_MONITOR)
51 defer.returnValue(cls)
52 else:

Subscribers

People subscribed via source and target branches