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: RotatingFileHandler

File 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.

Open the specified file and use it as the stream for logging.

By default, the file grows indefinitely. You can specify particular values of maxBytes and backupCount to allow the file to rollover at a predetermined size.

Rollover occurs whenever the current log file is nearly maxBytes in length. If backupCount is >= 1, the system will successively create new files with the same pathname as the base file, but with extensions “.1”, “.2” etc. appended to it. For example, with a backupCount of 5 and a base file name of “app.log”, you would get “app.log”, “app.log.1”, “app.log.2”, … through to “app.log.5”. The file being written to is always “app.log” - when it gets filled up, it is closed and renamed to “app.log.1”, and if files “app.log.1”, “app.log.2” etc. exist, then they are renamed to “app.log.2”, “app.log.3” etc. respectively.

If maxBytes is zero, rollover never occurs.

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: Handler

Custom logging handler that writes to QGIS message log.

Initialize handler with a specific tag for 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) Logger

Get a configured logger for the plugin.

Parameters:

name – Name of the logger (typically __name__ from calling module)

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.