plover.log – Logging

This module provides logging functionality, with an API based on that of the built-in logging module.

class plover.log.Logger

Initializes a logger with a handler that outputs to the console. A Logger may also log to a file, and may also log strokes and translations if enabled.

set_level(level: int)

Sets the minimum log level to emit messages to the print and file handlers.

setup_logfile()

Sets up a log handler that saves logs to a file in the configuration directory, rotating log files as needed.

setup_platform_handler()

Sets up a platform-specific GUI notification handler. This sets up a a DBus handler on Linux, a Notification Center handler on macOS, and a Plyer handler on Windows. Platform-specific handlers are expected to emit log messages of at least WARNING severity.

If a handler has already been set up, this does nothing.

has_platform_handler()

Returns whether a platform handler has been set up.

set_stroke_filename([filename: str = None])

Sets the name of the file to save stroke and translation logs to, and sets up stroke and translation handling.

enable_stroke_logging(enable: bool)

If enable is True, enable logging strokes; otherwise, disable it.

enable_translation_logging(enable: bool)

If enable is True, enable logging translations; otherwise, disable it.

log_stroke(stroke: plover.steno.Stroke)

Logs stroke to the stroke log file. Does nothing if the stroke logging handler is not set up, or stroke logging is disabled.

log_translation(undo, do, prev)

Aside from the methods above, the typical logging.Logger methods can be used, such as info and add_handler.

In addition to the Logger class above, the following module-level functions are also available for convenience:

plover.log.__logger: Logger

The global Plover logger instance. You should typically not have to access this directly; most use cases can be handled by the functions below.

plover.log.debug(msg, *args, **kwargs)

Logs at a DEBUG log level by calling __logger.debug.

plover.log.info(msg, *args, **kwargs)

Logs at an INFO log level by calling __logger.info.

plover.log.warning(msg, *args, **kwargs)

Logs at a WARNING log level by calling __logger.warning.

plover.log.error(msg, *args, **kwargs)

Logs at an ERROR log level by calling __logger.error.

plover.log.stroke(stroke)

Logs stroke by calling __logger.log_stroke.

plover.log.translation(undo, do, prev)

Logs the translation by calling __logger.log_translation.

plover.log.set_level(level)

Sets the minimum log level for __logger.

plover.log.add_handler(handler)

Adds a log handler to __logger.

plover.log.remove_handler(handler)

Removes a log handler from __logger.

plover.log.setup_logfile()

Sets up file logging for __logger.

plover.log.setup_platform_handler()

Calls __logger.setup_platform_handler.

plover.log.has_platform_handler()

Calls __logger.has_platform_handler.

plover.log.set_stroke_filename([filename=None])

Sets the filename to log strokes to for __logger.

plover.log.enable_stroke_logging(enable)

Enable or disable stroke logging for __logger.

plover.log.enable_translation_logging(enable)

Enable or disable translation logging for __logger.