twisted.logger.LogBeginner(object)
class documentationtwisted.logger
View Source
(View In Hierarchy)
A LogBeginner
holds state related to logging before logging has begun, and begins logging
when told to do so. Logging "begins" when someone has selected a
set of observers, like, for example, a FileLogObserver
that writes to a file on disk, or to standard output.
Applications will not typically need to instantiate this class, except
those which intend to initialize the global logging system themselves,
which may wish to instantiate this for testing. The global instance for
the current process is exposed as twisted.logger.globalLogBeginner
.
Before logging has begun, a LogBeginner
will:
LimitedHistoryLogObserver
.
Method | __init__ | Undocumented |
Method | beginLoggingTo | Begin logging to the given set of observers. This will: |
Method | showwarning | Twisted-enabled wrapper around warnings.showwarning . |
Instance Variable | _initialBuffer | A buffer of messages logged before logging began. (type: LimitedHistoryLogObserver ) |
Instance Variable | _publisher | The log publisher passed in to LogBeginner 's
constructor. (type: LogPublisher ) |
Instance Variable | _log | The logger used to log messages about the operation of the LogBeginner itself. (type: Logger ) |
Instance Variable | _temporaryObserver | If not None , an ILogObserver that
observes events on _publisher for this LogBeginner . (type: ILogObserver or
NoneType ) |
Instance Variable | _stdio | An object with stderr and stdout attributes (like
the sys
module) which will be replaced when redirecting standard I/O. (type: object ) |
LimitedHistoryLogObserver
)
LogBeginner
itself. (type: Logger
)
None
, an ILogObserver
that
observes events on _publisher
for this LogBeginner
. (type: ILogObserver
or
NoneType
)
Begin logging to the given set of observers. This will:
observers
to the LogPublisher
associated with this LogBeginner
.
discardBuffer
is not set.
LogPublisher
as strings to the errorStream
associated with this LogBeginner
,
and allow them to be logged normally.
warnings
module associated with this LogBeginner
to
log messages.
Parameters | observers | The observers to register. (type: iterable of ILogObserver s) |
discardBuffer | Whether to discard the buffer and not re-play it to the added observers.
(This argument is provided mainly for compatibility with legacy concerns.) (type: bool ) | |
redirectStandardIO | If true, redirect standard output and standard error to the observers. (type: bool ) | |
Note | Since a LogBeginner is
designed to encapsulate the transition between process-startup and
log-system-configuration, this method is intended to be invoked
once. |
Twisted-enabled wrapper around warnings.showwarning
.
If file
is None
, the default behaviour is to
emit the warning to the log system, otherwise the original warnings.showwarning
Python function is called.
Parameters | message | A warning message to emit. (type: str ) |
category | A warning category to associate with message . (type: warnings.Warning ) | |
filename | A file name for the source code file issuing the warning. | |
lineno | A line number in the source file where the warning was issued. (type: int ) | |
file | A file to write the warning message to. If None , write to sys.stderr . (type: file-like object) | |
line | A line of source code to include with the warning message. If
None , attempt to read the line from filename and
lineno . (type: str ) |