twisted.logger._format module documentationtwisted.logger
View Source
Tools for formatting logging events.
| Function | formatUnformattableEvent | Formats an event as a unicode that
describes the event generically and a formatting error. |
| Class | CallMapping | Read-only mapping that turns a ()-suffix in key names into
an invocation of the key rather than a lookup of the key. |
| Function | formatWithCall | Format a string like unicode.format,
but: |
| Function | _formatEvent | Formats an event as a unicode, using
the format in event["log_format"]. |
| Function | _formatTraceback | No summary |
| Function | _formatSystem | No summary |
Format a string like unicode.format,
but:
str'd, rather than calling str on the element
directly as normal.
For example:
>>> formatWithCall("{string}, {function()}.",
... dict(string="just a string",
... function=lambda: "a function"))
'just a string, a function.'
| Parameters | formatString | A PEP-3101 format string. (type: unicode) |
| mapping | A dict-like
object to format. | |
| Returns | The string with formatted values interpolated. (type: unicode) | |
Formats an event as a unicode, using
the format in event["log_format"].
This implementation should never raise an exception; if the formatting cannot be done, the returned string will describe the event generically so that a useful message is emitted regardless.
| Parameters | event | A logging event. (type: dict) |
| Returns | A formatted string. (type: unicode) | |
Format a failure traceback, assuming UTF-8 and using a replacement strategy for errors. Every effort is made to provide a usable traceback, but should not that not be possible, a message and the captured exception are logged.
| Parameters | failure | The failure to retrieve a traceback from. (type: twisted.python.failure.Failure) |
| Returns | The formatted traceback. (type: unicode) | |
Format the system specified in the event in the "log_system"
key if set, otherwise the "log_namespace" and
"log_level", joined by a
u"#". Each defaults to u"-"
is not set. If formatting fails completely, "UNFORMATTABLE" is
returned.
| Parameters | event | The event containing the system specification. (type: dict) |
| Returns | A formatted string representing the "log_system" key. (type: unicode) | |