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
def formatUnformattableEvent(event, error): (source)

Formats an event as a unicode that describes the event generically and a formatting error.

ParameterseventA logging event. (type: dict)
errorThe formatting error. (type: Exception)
ReturnsA formatted string. (type: unicode)
def formatWithCall(formatString, mapping): (source)

Format a string like unicode.format, but:

  • taking only a name mapping; no positional arguments
  • with the additional syntax that an empty set of parentheses correspond to a formatting item that should be called, and its result 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.'
ParametersformatStringA PEP-3101 format string. (type: unicode)
mappingA dict-like object to format.
ReturnsThe string with formatted values interpolated. (type: unicode)
def _formatEvent(event): (source)

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.

ParameterseventA logging event. (type: dict)
ReturnsA formatted string. (type: unicode)
def _formatTraceback(failure): (source)

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.

ParametersfailureThe failure to retrieve a traceback from. (type: twisted.python.failure.Failure)
ReturnsThe formatted traceback. (type: unicode)
def _formatSystem(event): (source)

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.

ParameterseventThe event containing the system specification. (type: dict)
ReturnsA formatted string representing the "log_system" key. (type: unicode)
API Documentation for Twisted, generated by pydoctor at 2019-08-06 12:10:50.