class LogPublisher: (source)
Constructor: LogPublisher(observerPublisher, publishPublisher, logBeginner, warningsModule)
Class for singleton log message publishing.
Method | __init__ |
Undocumented |
Method | add |
Add a new observer. |
Method | msg |
Log a new message. |
Method | remove |
Remove an observer. |
Class Variable | synchronized |
Undocumented |
Instance Variable | showwarning |
Undocumented |
Property | observers |
Property returning all observers registered on this LogPublisher . |
Method | _start |
Begin logging to the LogBeginner associated with this LogPublisher . |
Method | _stop |
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 . |
Instance Variable | _legacy |
Undocumented |
Instance Variable | _log |
Undocumented |
Instance Variable | _observer |
Undocumented |
Instance Variable | _oldshowwarning |
Undocumented |
Instance Variable | _publish |
Undocumented |
Instance Variable | _warnings |
Undocumented |
Undocumented
Add a new observer.
Parameters | |
other:Provider of ILogObserver | A callable object that will be called with each new log message (a dict). |
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')
Begin logging to the LogBeginner
associated with this LogPublisher
.
Parameters | |
other:LogBeginner | the observer to log to. |
setbool | if true, send standard I/O to the observer as well. |
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
.