devctrl.gui.widgets.log_viewer.LogSignal#

class LogSignal[source]#

Bases: Handler, QObject

Log handler that emits a QT signal when a record is made. Based on tobilocker’s answer in https://stackoverflow.com/questions/28655198/best-way-to-display-logs-in-pyqt

Initializes the instance - basically setting the formatter to None and the filter list to empty.

Methods

acquire

Acquire the I/O thread lock.

addFilter

Add the specified filter to this handler.

blockSignals

childEvent

children

close

Tidy up any resources used by the handler.

connectNotify

createLock

Acquire a thread lock for serializing access to the underlying I/O.

customEvent

deleteLater

disconnect

disconnectNotify

dumpObjectInfo

dumpObjectTree

dynamicPropertyNames

emit

Do whatever it takes to actually log the specified logging record.

event

eventFilter

filter

Determine if a record is loggable by consulting all the filters.

findChild

findChildren

flush

Ensure all logging output has been flushed.

format

Format the specified record.

get_name

handle

Conditionally emit the specified logging record.

handleError

Handle errors which occur during an emit() call.

inherits

installEventFilter

isQuickItemType

isSignalConnected

isWidgetType

isWindowType

killTimer

metaObject

moveToThread

objectName

parent

property

pyqtConfigure

Each keyword argument is either the name of a Qt property or a Qt signal.

receivers

release

Release the I/O thread lock.

removeEventFilter

removeFilter

Remove the specified filter from this handler.

sender

senderSignalIndex

setFormatter

Set the formatter for this handler.

setLevel

Set the logging level of this handler.

setObjectName

setParent

setProperty

set_name

signalsBlocked

startTimer

thread

timerEvent

tr

Attributes

destroyed

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

name

newLogRecord

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

objectNameChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

staticMetaObject

acquire()#

Acquire the I/O thread lock.

addFilter(filter)#

Add the specified filter to this handler.

classmethod blockSignals(self, b: bool) bool#
classmethod childEvent(self, a0: QChildEvent | None)#
classmethod children(self) list[QObject]#
close()#

Tidy up any resources used by the handler.

This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.

classmethod connectNotify(self, signal: QMetaMethod)#
createLock()#

Acquire a thread lock for serializing access to the underlying I/O.

classmethod customEvent(self, a0: QEvent | None)#
classmethod deleteLater(self)#
classmethod disconnect(a0: QMetaObject.Connection) bool#
classmethod disconnect(self)
classmethod disconnectNotify(self, signal: QMetaMethod)#
classmethod dumpObjectInfo(self)#
classmethod dumpObjectTree(self)#
classmethod dynamicPropertyNames(self) list[QByteArray]#
emit(record)[source]#

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

classmethod event(self, a0: QEvent | None) bool#
classmethod eventFilter(self, a0: QObject | None, a1: QEvent | None) bool#
filter(record)#

Determine if a record is loggable by consulting all the filters.

The default is to allow the record to be logged; any filter can veto this by returning a false value. If a filter attached to a handler returns a log record instance, then that instance is used in place of the original log record in any further processing of the event by that handler. If a filter returns any other true value, the original log record is used in any further processing of the event by that handler.

If none of the filters return false values, this method returns a log record. If any of the filters return a false value, this method returns a false value.

Changed in version 3.2: Allow filters to be just callables.

Changed in version 3.12: Allow filters to return a LogRecord instead of modifying it in place.

classmethod findChild(self, type: type[QObjectT], name: str | None = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObjectT#
classmethod findChild(self, types: tuple[type[QObjectT], ...], name: str | None = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) QObjectT
classmethod findChildren(self, type: type[QObjectT], name: str | None = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) list[QObjectT]#
classmethod findChildren(self, types: tuple[type[QObjectT], ...], name: str | None = '', options: Qt.FindChildOption = Qt.FindChildrenRecursively) list[QObjectT]
classmethod findChildren(self, type: type[QObjectT], re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) list[QObjectT]
classmethod findChildren(self, types: tuple[type[QObjectT], ...], re: QRegularExpression, options: Qt.FindChildOption = Qt.FindChildrenRecursively) list[QObjectT]
flush()#

Ensure all logging output has been flushed.

This version does nothing and is intended to be implemented by subclasses.

format(record)#

Format the specified record.

If a formatter is set, use it. Otherwise, use the default formatter for the module.

handle(record)#

Conditionally emit the specified logging record.

Emission depends on filters which may have been added to the handler. Wrap the actual emission of the record with acquisition/release of the I/O thread lock.

Returns an instance of the log record that was emitted if it passed all filters, otherwise a false value is returned.

handleError(record)#

Handle errors which occur during an emit() call.

This method should be called from handlers when an exception is encountered during an emit() call. If raiseExceptions is false, exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The record which was being processed is passed in to this method.

classmethod inherits(self, classname: str | None) bool#
classmethod installEventFilter(self, a0: QObject | None)#
classmethod isQuickItemType(self) bool#
classmethod isSignalConnected(self, signal: QMetaMethod) bool#
classmethod isWidgetType(self) bool#
classmethod isWindowType(self) bool#
classmethod killTimer(self, id: int)#
classmethod metaObject(self) QMetaObject | None#
classmethod moveToThread(self, thread: QThread | None)#
classmethod objectName(self) str#
classmethod parent(self) QObject | None#
classmethod property(self, name: str | None) Any#
classmethod pyqtConfigure(...)#

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

classmethod receivers(self, signal: PYQT_SIGNAL) int#
release()#

Release the I/O thread lock.

classmethod removeEventFilter(self, a0: QObject | None)#
removeFilter(filter)#

Remove the specified filter from this handler.

classmethod sender(self) QObject | None#
classmethod senderSignalIndex(self) int#
setFormatter(fmt)#

Set the formatter for this handler.

setLevel(level)#

Set the logging level of this handler. level must be an int or a str.

classmethod setObjectName(self, name: QByteArray | bytes | bytearray | memoryview | str | None)#
classmethod setParent(self, a0: QObject | None)#
classmethod setProperty(self, name: str | None, value: Any) bool#
classmethod signalsBlocked(self) bool#
classmethod startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int#
classmethod thread(self) QThread | None#
classmethod timerEvent(self, a0: QTimerEvent | None)#
classmethod tr(sourceText: str | None, disambiguation: str | None = None, n: int = -1) str#