Changeset 477:c8aca5d2edc1
- Timestamp:
- 08/29/08 13:00:45
(4 months ago)
- Author:
- Brian Warner <warner@allmydata.com>
- branch:
- default
- Message:
logging: move app_versions out to a separate module, provide a setter
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r476 |
r477 |
|
| | 1 | 2008-08-29 Brian Warner <warner@lothar.com> |
|---|
| | 2 | |
|---|
| | 3 | * foolscap/logging/app_versions.py (versions): move the |
|---|
| | 4 | application version dict (which gets reported to remote |
|---|
| | 5 | subscribers, and copied into logfiles) to a separate module. It |
|---|
| | 6 | was causing circular import problems when it lived in an attribute |
|---|
| | 7 | of LogPublisher. |
|---|
| | 8 | (add_version): provide a setter method |
|---|
| | 9 | * foolscap/logging/publish.py (LogPublisher.versions): same |
|---|
| | 10 | (LogPublisher.remote_get_versions): same |
|---|
| | 11 | * foolscap/logging/incident.py (IncidentReporter.incident_declared): |
|---|
| | 12 | same |
|---|
| | 13 | |
|---|
| | 14 | * foolscap/test/test_logging.py (IncidentGatherer.test_emit): |
|---|
| | 15 | improve test shutdown a little bit |
|---|
| | 16 | |
|---|
| 1 | 17 | 2008-08-28 Brian Warner <warner@lothar.com> |
|---|
| 2 | 18 | |
|---|
| r476 |
r477 |
|
| 4 | 4 | from twisted.internet import reactor |
|---|
| 5 | 5 | from foolscap.logging.interfaces import IIncidentReporter |
|---|
| 6 | | from foolscap.logging import levels |
|---|
| | 6 | from foolscap.logging import levels, app_versions |
|---|
| 7 | 7 | from foolscap.eventual import eventually |
|---|
| 8 | 8 | from foolscap import base32 |
|---|
| … | … | |
| 84 | 84 | self.f2 = bz2.BZ2File(self.abs_filename_bz2_tmp, "wb") |
|---|
| 85 | 85 | |
|---|
| 86 | | # there's some weird circular import that prevents this from being |
|---|
| 87 | | # imported at the top level |
|---|
| 88 | | from foolscap.logging.publish import LogPublisher |
|---|
| 89 | | versions = LogPublisher.versions |
|---|
| 90 | | |
|---|
| 91 | 86 | # write header with triggering_event |
|---|
| 92 | 87 | header = {"header": {"type": "incident", |
|---|
| 93 | 88 | "trigger": triggering_event, |
|---|
| 94 | | "versions": versions, |
|---|
| | 89 | "versions": app_versions.versions, |
|---|
| 95 | 90 | }} |
|---|
| 96 | 91 | pickle.dump(header, self.f1) |
|---|
| r440 |
r477 |
|
| 9 | 9 | from foolscap.referenceable import Referenceable |
|---|
| 10 | 10 | from foolscap.logging.interfaces import RISubscription, RILogPublisher |
|---|
| | 11 | from foolscap.logging import app_versions |
|---|
| 11 | 12 | from foolscap.eventual import eventually |
|---|
| 12 | 13 | |
|---|
| … | … | |
| 164 | 165 | implements(RILogPublisher) |
|---|
| 165 | 166 | |
|---|
| 166 | | # you might want to modify this to include the version of your |
|---|
| 167 | | # application. Just do: |
|---|
| 168 | | # from foolscap.logging.publish import LogPublisher |
|---|
| 169 | | # LogPublisher.versions['myapp'] = myversion |
|---|
| 170 | | |
|---|
| 171 | | versions = {"twisted": twisted.__version__, |
|---|
| 172 | | "foolscap": foolscap.__version__, |
|---|
| 173 | | } |
|---|
| | 167 | # the 'versions' dict used to live here in LogPublisher, but now it lives |
|---|
| | 168 | # in foolscap.logging.app_versions and should be accessed from there. |
|---|
| | 169 | # This copy remains for backwards-compatibility. |
|---|
| | 170 | versions = app_versions.versions |
|---|
| 174 | 171 | |
|---|
| 175 | 172 | def __init__(self, logger): |
|---|
| … | … | |
| 178 | 175 | |
|---|
| 179 | 176 | def remote_get_versions(self): |
|---|
| 180 | | return self.versions |
|---|
| | 177 | return app_versions.versions |
|---|
| 181 | 178 | def remote_get_pid(self): |
|---|
| 182 | 179 | return os.getpid() |
|---|
| r476 |
r477 |
|
| 1100 | 1100 | self.poll(lambda : self.ig4.incidents_received == 2)) |
|---|
| 1101 | 1101 | |
|---|
| 1102 | | d.addCallback(self.stall, 0.5) |
|---|
| | 1102 | d.addBoth(self.stall, 0.5) # allow shutdown even on error |
|---|
| 1103 | 1103 | |
|---|
| 1104 | 1104 | return d |
|---|