madgui.widget.log module¶
This module defines the parts involved in redirecting all logging events to a window.
Classes
|
|
|
Widget that shows log domain and time next to the log widget text. |
|
Simple log window based on QPlainTextEdit using ExtraSelection to |
|
Handler class that is needed for forwarding |
-
class
madgui.widget.log.LogRecord(time, domain, text)¶ Bases:
tupleAttributes
Alias for field number 1
Alias for field number 2
Alias for field number 0
-
property
domain¶ Alias for field number 1
-
property
text¶ Alias for field number 2
-
property
time¶ Alias for field number 0
-
property
-
class
madgui.widget.log.LogWindow(*args)[source]¶ Bases:
PyQt5.QtWidgets.QFrameSimple log window based on QPlainTextEdit using ExtraSelection to highlight input/output sections with different backgrounds, see: http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html
Methods
append(record)Add a
LogRecord.append_from_binary_stream(domain, text[, …])Append a log record from a binary utf-8 text stream.
enable(domain, enable)Turn on/off log records with the given domain.
enable_logging(enable)Turn on/off display of
logginglog events.enabled(domain)Return if the given domain is configured to be displayed.
excepthook(*args, **kwargs)Exception handler that prints exceptions and appends a log record instead of exiting.
has_entries(domain)Return if any log records with the given domain have been emitted.
highlight(domain, color)Configure log records with the given domain to be colorized in the given color.
Clear and reinsert all configured log records into the text control.
set_loglevel(loglevel)Set minimum log level of displayed log events.
setup_logging(level, fmt)Redirect exceptions and
loggingto this widget.Attributes
Maximum number of displayed log records.
-
append_from_binary_stream(domain, text, encoding='utf-8')[source]¶ Append a log record from a binary utf-8 text stream.
-
excepthook(*args, **kwargs)[source]¶ Exception handler that prints exceptions and appends a log record instead of exiting.
-
has_entries(domain: str) → bool[source]¶ Return if any log records with the given domain have been emitted.
-
highlight(domain: str, color: PyQt5.QtGui.QColor)[source]¶ Configure log records with the given domain to be colorized in the given color.
-
property
maxlen¶ Maximum number of displayed log records. Default is
0which means infinite.
-
-
class
madgui.widget.log.RecordHandler(log_window: madgui.widget.log.LogWindow)[source]¶ Bases:
logging.HandlerHandler class that is needed for forwarding
logginglog events toLogWindow.This class is instanciated by
LogWindow.setup_logging()and there should be no need to instanciate it anywhere else.Methods
emit(record)Override
logging.Handler.emit()to append toLogWindow.-
emit(record)[source]¶ Override
logging.Handler.emit()to append toLogWindow.
-
-
class
madgui.widget.log.RecordInfoBar(edit, time_format='%H:%M:%S', show_time=True)[source]¶ Bases:
madgui.widget.edit.LineNumberBarWidget that shows log domain and time next to the log widget text.
This class is taylored toward the behaviour of
LogWindowand should not be instanciated from elsewhere.Methods
add_record(record)Called by
LogWindowwhen it adds a visible record.calc_width(count)Calculate the required widget width in pixels.
clear()Called by
LogWindowbefore rebuilding the list of displayed records.draw_block(painter, rect, block, first)Draw the info corresponding to a given block (text line) of the text document.
enable_timestamps(enable)Turn on display of times, recalculate geometry, and redraw.
set_timeformat(format)Set a time display format for use with
time.strftime(), recalculate geometry, and redraw.-
add_record(record: madgui.widget.log.LogRecord)[source]¶ Called by
LogWindowwhen it adds a visible record.
-
calc_width(count: int = 0) → int[source]¶ Calculate the required widget width in pixels.
- Parameters
count (int) – ignored here
This overrides
LineNumberBar.calc_width.
-
draw_block(painter, rect, block, first)[source]¶ Draw the info corresponding to a given block (text line) of the text document.
This overrides
LineNumberBar.draw_block.- Parameters
painter (QPainter) – painter for the current widget
rect (QRect) – clipping rect for the text to be drawn
block (QTextBlock) – associated text block in the text edit
first (bool) – indicates the topmost visible block on screen
-
enable_timestamps(enable: bool)[source]¶ Turn on display of times, recalculate geometry, and redraw.
-
set_timeformat(format: str)[source]¶ Set a time display format for use with
time.strftime(), recalculate geometry, and redraw.
-