twisted.logger.eventAsText(event, includeTraceback=True, includeTimestamp=True, includeSystem=True, formatTime=formatTime)
function documentationtwisted.logger
View Source
Format an event as a unicode string. Optionally, attach timestamp, traceback, and system information.
The full output format is: u"{timeStamp} [{system}]
{event}\n{traceback}\n"
where:
timeStamp
is the event's "log_time"
value formatted with the provided formatTime
callable.
system
is the event's "log_system"
value, if set, otherwise, the "log_namespace"
and "log_level"
, joined by a
u"#"
. Each defaults to
u"-"
is not set.
event
is the event, as formatted by formatEvent
.
traceback
is the traceback if the event contains a
"log_failure"
key. In the event the original
traceback cannot be formatted, a message indicating the failure will be
substituted.
If the event cannot be formatted, and no traceback exists, an empty string is returned, even if includeSystem or includeTimestamp are true.
Parameters | event | A logging event. (type: dict ) |
includeTraceback | If true and a "log_failure" key exists, append a
traceback. (type: bool ) | |
includeTimestamp | If true include a formatted timestamp before the event. (type: bool ) | |
includeSystem | If true, include the event's "log_system" value. (type: bool ) | |
formatTime | A time formatter (type: callable
that takes an event argument and returns a unicode ) | |
Returns | A formatted string with specified options. (type: unicode ) | |
Present Since | Twisted 18.9.0 |