Package foolscap :: Package logging :: Module gatherer :: Class GathererService
[hide private]
[frames] | no frames]

Class GathererService

source code

 twisted.application.service.Service --+        
                                       |        
twisted.application.service.MultiService --+    
                                           |    
                          object --+       |    
                                   |       |    
     referenceable.OnlyReferenceable --+   |    
                                       |   |    
             referenceable.Referenceable --+    
                                           |    
                               GatheringBase --+
                                               |
                                              GathererService

Run a service that gathers logs from multiple applications.

The LogGatherer sits in a corner and receives log events from many applications at once. At startup, it runs a Tub and emits the gatherer's long-term FURL. You can then configure your applications to connect to this FURL when they start and pass it a reference to their LogPublisher. The gatherer will subscribe to the publisher and save all the resulting messages in a logs.pickle file.

Applications can use code like the following to create a LogPublisher and pass it to the gatherer:

def tub_ready(self):
    # called when the Tub is available for registerReference
    lp = LogPublisher('logport.furl')
    lp.setServiceParent(self.tub)
    log_gatherer_furl = self.get_config('log_gatherer.furl')
    if log_gatherer_furl:
        self.tub.connectTo(log_gatherer_furl,
                           self._log_gatherer_connected, lp)

def _log_gatherer_connected(self, rref, lp):
    rref.callRemote('logport', self.nodeid, lp)

This LogGatherer class is meant to be run by twistd from a .tac file, but applications that want to provide the same functionality can just instantiate it with a distinct basedir= and call startService.

Nested Classes [hide private]

Inherited from GatheringBase: tub_class

Instance Methods [hide private]
 
__init__(self, rotate, use_bzip, basedir=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_handle_SIGHUP(self, *args) source code
 
startService(self) source code
 
format_time(self, when) source code
 
_open_savefile(self, now) source code
 
do_rotate(self) source code
 
remote_logport(self, nodeid, publisher) source code
 
msg(self, nodeid_s, d) source code

Inherited from GatheringBase: tub_ready

Inherited from twisted.application.service.MultiService: __iter__, addService, getServiceNamed, privilegedStartService, removeService, stopService

Inherited from twisted.application.service.Service: __getstate__, __providedBy__, disownServiceParent, setName, setServiceParent

Inherited from referenceable.Referenceable: doRemoteCall, getInterface, getInterfaceName

Inherited from referenceable.OnlyReferenceable: processUniqueID

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  verbose = True
  furlFile = 'log_gatherer.furl'
  tacFile = 'gatherer.tac'
  TIME_FORMAT = '%Y-%m-%d-%H%M%S'
  __implemented__ = <implementedBy foolscap.logging.gatherer.Gat...
  __provides__ = <zope.interface.declarations.ClassProvides obje...

Inherited from GatheringBase: use_local_addresses

Inherited from twisted.application.service.Service: name, parent, running

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, rotate, use_bzip, basedir=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

startService(self)

source code 
Overrides: twisted.application.service.Service.startService

Class Variable Details [hide private]

__implemented__

Value:
<implementedBy foolscap.logging.gatherer.GathererService>

__provides__

Value:
<zope.interface.declarations.ClassProvides object at 0x927d30c>