t.p.log : module documentation

Part of twisted.python View Source

Logging and metrics infrastructure.
Class ILogContext Actually, this interface is just a synoym for the dictionary interface, but it serves as a key for the default information in a log.
Interface ILogObserver An observer which can do something with log events.
Function callWithContext Undocumented
Function callWithLogger Utility method which wraps a function in a try:/except:, logs a failure if one occurrs, and uses the system's logPrefix.
Function startKeepingErrors DEPRECATED in Twisted 2.5.
Function flushErrors DEPRECATED in Twisted 2.5. See TestCase.flushLoggedErrors.
Function ignoreErrors DEPRECATED
Function clearIgnores DEPRECATED
Function err Write a failure to the log.
Class Logger This represents a class which may 'own' a log. Used by subclassing.
Class LogPublisher Class for singleton log message publishing.
Function textFromEventDict Extract text from an event dict passed to a log observer. If it cannot handle the dict, it returns None.
Class FileLogObserver Log observer that writes to a file-like object.
Class PythonLoggingObserver Output twisted messages to Python standard library logging module.
Class StdioOnnaStick Class that pretends to be stout/err.
Function startLogging Initialize logging to a specified file.
Function startLoggingWithObserver Initialize logging to a specified observer. If setStdout is true (defaults to yes), also redirect sys.stdout and sys.stderr to the specified file.
Class NullFile Undocumented
Function discardLogs Throw away all logs.
Class DefaultObserver Default observer.
Function _flushErrors PRIVATE. DEPRECATED. DON'T USE.
Function _ignore PRIVATE. DEPRECATED. DON'T USE.
Function _clearIgnores PRIVATE. DEPRECATED. DON'T USE.
Function _safeFormat Try to format the string fmtString using fmtDict arguments, swallowing all errors to always return a string.
def callWithContext(ctx, func, *args, **kw): (source)
Undocumented
def callWithLogger(logger, func, *args, **kw): (source)
Utility method which wraps a function in a try:/except:, logs a failure if one occurrs, and uses the system's logPrefix.
def startKeepingErrors(): (source)

DEPRECATED in Twisted 2.5.

Support function for testing frameworks.

Start keeping errors in a buffer which can be retrieved (and emptied) with flushErrors.
def flushErrors(*errorTypes): (source)

DEPRECATED in Twisted 2.5. See TestCase.flushLoggedErrors.

Support function for testing frameworks.

Return a list of errors that occurred since the last call to flushErrors(). (This will return None unless startKeepingErrors has been called.)
def _flushErrors(*errorTypes): (source)
PRIVATE. DEPRECATED. DON'T USE.
def ignoreErrors(*types): (source)
DEPRECATED
def _ignore(*types): (source)
PRIVATE. DEPRECATED. DON'T USE.
def clearIgnores(): (source)
DEPRECATED
def _clearIgnores(): (source)
PRIVATE. DEPRECATED. DON'T USE.
def err(_stuff=None, _why=None, **kw): (source)

Write a failure to the log.

The _stuff and _why parameters use an underscore prefix to lessen the chance of colliding with a keyword argument the application wishes to pass. It is intended that they be supplied with arguments passed positionally, not by keyword.
Parameters_stuffThe failure to log. If _stuff is None a new Failure will be created from the current exception state. If _stuff is an Exception instance it will be wrapped in a Failure. (type: NoneType, Exception, or Failure. )
_whyThe source of this failure. This will be logged along with _stuff and should describe the context in which the failure occurred. (type: str )
def _safeFormat(fmtString, fmtDict): (source)
Try to format the string fmtString using fmtDict arguments, swallowing all errors to always return a string.
def textFromEventDict(eventDict): (source)

Extract text from an event dict passed to a log observer. If it cannot handle the dict, it returns None.

The possible keys of eventDict are:
  • message: by default, it holds the final text. It's required, but can be empty if either isError or format is provided (the first having the priority).
  • isError: boolean indicating the nature of the event.
  • failure: failure.Failure instance, required if the event is an error.
  • why: if defined, used as header of the traceback in case of errors.
  • format: string format used in place of message to customize the event. It uses all keys present in eventDict to format the text.
Other keys will be used when applying the format, or ignored.
def startLogging(file, *a, **kw): (source)
Initialize logging to a specified file.
ReturnsA FileLogObserver if a new observer is added, None otherwise.
def startLoggingWithObserver(observer, setStdout=1): (source)
Initialize logging to a specified observer. If setStdout is true (defaults to yes), also redirect sys.stdout and sys.stderr to the specified file.
def discardLogs(): (source)
Throw away all logs.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:27:37.