instrumentserver.log#

instrumentserver.log : Logging tools and defaults for instrumentserver.

Functions

log(logger, message, level)

Simple wrapper to log messages.

logger([name])

Get the (root) logger for the package.

setupLogging([addStreamHandler, logFile, ...])

Setting up logging, including adding a custom handler.

Classes

LogLevels(*values)

LogWidget([parent, level])

A simple logger widget.

QLogHandler(parent)

A simple log handler that supports logging in TextEdit

class instrumentserver.log.LogLevels(*values)[source]#

Bases: Enum

debug = 4#
error = 1#
info = 3#
warn = 2#
class instrumentserver.log.LogWidget(parent: QWidget | None = None, level: int = 20)[source]#

Bases: QWidget

A simple logger widget. Uses QLogHandler as handler. The handler has the actual widget that is used to display the logs.

class instrumentserver.log.QLogHandler(parent: QWidget | None)[source]#

Bases: QObject, Handler

A simple log handler that supports logging in TextEdit

COLORS = {10: <PyQt5.QtGui.QColor object>, 20: <PyQt5.QtGui.QColor object>, 30: <PyQt5.QtGui.QColor object>, 40: <PyQt5.QtGui.QColor object>}#
emit(record: LogRecord) None[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.

new_html#

Emitted with the html-formatted log record to append to the widget

Type:

Signal(str)

set_transform(fn: Callable[[LogRecord, str], str | None]) None[source]#

fn(record, msg) -> str | {‘html’: str} | None

instrumentserver.log.log(logger: Logger, message: str, level: LogLevels) None[source]#

Simple wrapper to log messages.

Useful when the log level is a variable.

instrumentserver.log.logger(name: str = 'instrumentserver') Logger[source]#

Get the (root) logger for the package.

instrumentserver.log.setupLogging(addStreamHandler: bool = True, logFile: str | None = None, name: str = 'instrumentserver', streamHandlerLevel: int = 20) None[source]#

Setting up logging, including adding a custom handler.