This module defines custom logging records and handlers.
- class maestral.logging.CachedHandler(level=0, maxlen=None)¶
Handler which stores past records
This is used to populate Maestral’s status and error interfaces. The method
wait_for_emit()can be used from another thread to block until a new record is emitted, for instance to react to state changes.
- Return type
Logs the specified log record and saves it to the cache.
Blocks until a new record is emitted.
- class maestral.logging.SdNotificationHandler(level=0)¶
Handler which emits messages as systemd notifications
This is useful when used from a systemd service and will do nothing when no NOTIFY_SOCKET is provided.
Initializes the instance - basically setting the formatter to None and the filter list to empty.
- notifier = <sdnotify.SystemdNotifier object>¶
- maestral.logging.setup_logging(config_name, log_to_stderr=True)¶
Sets up logging handlers for the given config name. The following handlers are installed for the root logger:
RotatingFileHandler: Writes logs to the appropriate log file for the config. Log level is determined by the config value.
StreamHandler: Writes logs to stderr. Log level is determined by the config value. This will be replaced by a null handler if
SdNotificationHandler: Sends all log messages of level INFO and higher to the NOTIFY_SOCKET if provided as an environment variable. The log level is fixed.
JournalHandler: Writes logs to the systemd journal. Log level is determined by the config value. Will be replaced by a null handler if not started as a systemd service or if python-systemd is not installed.
Any previous loggers are cleared.
(log_handler_file, log_handler_stream, log_handler_sd, log_handler_journal)
- Return type