Tools for formatting logging events.
| Function | formatUnformattableEvent | Formats an event as text 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 str.format, but: |
| Function | _formatEvent | Formats an event as a string, using the format in event["log_format"]. |
| Function | _formatTraceback | No summary |
| Function | _formatSystem | No summary |
Formats an event as text that describes the event generically and a formatting error.
| Parameters | event | A logging event. (type: LogEvent) |
| error | The formatting error. (type: BaseException) | |
| Returns | A formatted string. (type: str) | |
Format a string like str.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: str) |
| mapping | A dict-like object to format. (type: Mapping[str, Any]) | |
| Returns | The string with formatted values interpolated. (type: str) | |
Formats an event as a string, 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: LogEvent) |
| Returns | A formatted string. (type: str) | |
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: Failure) |
| Returns | The formatted traceback. (type: str) | |
Format the system specified in the event in the "log_system" key if set, otherwise the "log_namespace" and "log_level", joined by a "#". Each defaults to "-" is not set. If formatting fails completely, "UNFORMATTABLE" is returned.
| Parameters | event | The event containing the system specification. (type: LogEvent) |
| Returns | A formatted string representing the "log_system" key. (type: str) | |