class documentation

class twisted.python.log.LogPublisher: (source)

View In Hierarchy

Class for singleton log message publishing.

Class Variable synchronized Undocumented
Method __init__ Undocumented
Instance Variable showwarning Undocumented
Property observers Property returning all observers registered on this LogPublisher.
Method addObserver Add a new observer.
Method removeObserver Remove an observer.
Method msg Log a new message.
Instance Variable _observerPublisher Undocumented
Instance Variable _publishPublisher Undocumented
Instance Variable _legacyObservers Undocumented
Instance Variable _logBeginner Undocumented
Instance Variable _warningsModule Undocumented
Instance Variable _oldshowwarning Undocumented
Method _startLogging Begin logging to the LogBeginner associated with this LogPublisher.
Method _stopLogging Clean-up hook for fixing potentially global state. Only for testing of this module itself. If you want less global state, use the new warnings system in twisted.logger.
synchronized = (source)

Undocumented

(type: list[str])
def __init__(self, observerPublisher=None, publishPublisher=None, logBeginner=None, warningsModule=warnings): (source)

Undocumented

_observerPublisher = (source)

Undocumented

_publishPublisher = (source)

Undocumented

_legacyObservers = (source)

Undocumented

(type: list)
_logBeginner = (source)

Undocumented

_warningsModule = (source)

Undocumented

_oldshowwarning = (source)

Undocumented

showwarning = (source)

Undocumented

@property
observers = (source)

Property returning all observers registered on this LogPublisher.

(type: list of callable)
def _startLogging(self, other, setStdout): (source)

Begin logging to the LogBeginner associated with this LogPublisher.

Parametersotherthe observer to log to. (type: LogBeginner)
setStdoutif true, send standard I/O to the observer as well. (type: bool)
def _stopLogging(self): (source)

Clean-up hook for fixing potentially global state. Only for testing of this module itself. If you want less global state, use the new warnings system in twisted.logger.

def addObserver(self, other): (source)

Add a new observer.

ParametersotherA callable object that will be called with each new log message (a dict). (type: Provider of ILogObserver)
def removeObserver(self, other): (source)

Remove an observer.

def msg(self, *message, **kw): (source)

Log a new message.

The message should be a native string, i.e. bytes on Python 2 and Unicode on Python 3. For compatibility with both use the native string syntax, for example:

    >>> log.msg('Hello, world.')

You MUST avoid passing in Unicode on Python 2, and the form:

    >>> log.msg('Hello ', 'world.')

This form only works (sometimes) by accident.

Keyword arguments will be converted into items in the event dict that is passed to ILogObserver implementations. Each implementation, in turn, can define keys that are used by it specifically, in addition to common keys listed at ILogObserver.__call__.

For example, to set the system parameter while logging a message:


>>> log.msg('Started', system='Foo')
API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.