sec_interp.logger_config module
Logger Configuration Module.
Provides centralized logging configuration for the Sec Interp plugin.
- class sec_interp.logger_config.ImmediateFlushFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False, errors=None)
Bases:
RotatingFileHandlerFile handler that flushes immediately after each write.
This ensures logs are written to disk before a crash occurs. Uses os.fsync() to force OS-level write to disk.
- emit(record: LogRecord) None
Emit a log record and flush immediately.
- Parameters:
record – The log record to emit.
- class sec_interp.logger_config.QgsLogHandler(tag: str = 'SecInterp')
Bases:
HandlerCustom logging handler that writes to QGIS message log.
- __init__(tag: str = 'SecInterp') None
Initialize handler with a specific tag for QGIS message log.
- emit(record: LogRecord) None
Emit a log record to QGIS message log safely.
- sec_interp.logger_config.get_logger(name: str | None = None) Logger
Get a configured logger for a plugin module.
- Parameters:
name – Name of the logger (typically __name__ from calling module). If None, returns the root plugin logger.
- Returns:
Configured logger instance.
- Return type:
logging.Logger
- sec_interp.logger_config.log_critical_operation(logger: Logger, operation_name: str, **context: Any) None
Log a critical operation with maximum persistence.
Use this before operations that might crash QGIS (e.g., canvas operations, rubber band manipulation, tool activation).
- Parameters:
logger – Logger instance.
operation_name – Name of the operation.
**context – Additional context to log.
- sec_interp.logger_config.setup_logging(level: int = 10) Logger
Configure the root logger for the plugin.
This should be called once at plugin initialization. It sets up handlers for QGIS message log, file logging with rotation, and stderr.
- Parameters:
level – Logging level for the root logger. Defaults to DEBUG.
- Returns:
The configured root logger.
- Return type:
logging.Logger