Changeset 477:c8aca5d2edc1

Show
Ignore:
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
  • ChangeLog

    r476 r477  
     12008-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 
    1172008-08-28  Brian Warner  <warner@lothar.com> 
    218 
  • foolscap/logging/incident.py

    r476 r477  
    44from twisted.internet import reactor 
    55from foolscap.logging.interfaces import IIncidentReporter 
    6 from foolscap.logging import levels 
     6from foolscap.logging import levels, app_versions 
    77from foolscap.eventual import eventually 
    88from foolscap import base32 
     
    8484        self.f2 = bz2.BZ2File(self.abs_filename_bz2_tmp, "wb") 
    8585 
    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  
    9186        # write header with triggering_event 
    9287        header = {"header": {"type": "incident", 
    9388                             "trigger": triggering_event, 
    94                              "versions": versions, 
     89                             "versions": app_versions.versions, 
    9590                             }} 
    9691        pickle.dump(header, self.f1) 
  • foolscap/logging/publish.py

    r440 r477  
    99from foolscap.referenceable import Referenceable 
    1010from foolscap.logging.interfaces import RISubscription, RILogPublisher 
     11from foolscap.logging import app_versions 
    1112from foolscap.eventual import eventually 
    1213 
     
    164165    implements(RILogPublisher) 
    165166 
    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 
    174171 
    175172    def __init__(self, logger): 
     
    178175 
    179176    def remote_get_versions(self): 
    180         return self.versions 
     177        return app_versions.versions 
    181178    def remote_get_pid(self): 
    182179        return os.getpid() 
  • foolscap/test/test_logging.py

    r476 r477  
    11001100                      self.poll(lambda : self.ig4.incidents_received == 2)) 
    11011101 
    1102         d.addCallback(self.stall, 0.5) 
     1102        d.addBoth(self.stall, 0.5) # allow shutdown even on error 
    11031103 
    11041104        return d