twisted.logger.Logger.failure(self, format, failure=None, level=LogLevel.critical, **kwargs)
method documentationtwisted.logger.__init__.Logger
View Source
Log a failure and emit a traceback.
For example:
try: frob(knob) except Exception: log.failure("While frobbing {knob}", knob=knob)
or:
d = deferredFrob(knob) d.addErrback(lambda f: log.failure, "While frobbing {knob}", f, knob=knob)
This method is generally meant to capture unexpected exceptions in code;
an exception that is caught and handled somehow should be logged, if
appropriate, via Logger.error
instead. If some unknown exception occurs and your code doesn't know how
to handle it, as in the above example, then this method provides a means to
describe the failure in nerd-speak. This is done at LogLevel.critical
by default, since no corrective guidance can be offered to an
user/administrator, and the impact of the condition is unknown.
Parameters | format | a message format using new-style (PEP 3101) formatting. The logging event
(which is a dict )
is used to render this format string. |
failure | a Failure to
log. If None ,
a Failure is
created from the exception in flight. | |
level | a LogLevel to use. | |
kwargs | additional key/value pairs to include in the event. Note that values which are later mutated may result in non-deterministic behavior from observers that schedule work for later execution. |