ogstools.logparser.log_file_handler module#

class ogstools.logparser.log_file_handler.LogFileHandler[source]#

Bases: FileSystemEventHandler

Parse the lines that OGS appends to a log file and put the records into a queue.

Parameters:
  • file_name (str | Path) – The location of the log file to monitor.

  • queue (Queue) – The queue where log entries are put and to be consumed.

  • status (Context) – The status of the simulation (e.g. current time step).

  • stop_callback (Callable[[], None]) – A callback function to stop the simulation.

  • line_limit (int) – The number of lines to read before stopping the simulation. 0 means no limit.

__init__(file_name, queue, status, stop_callback, line_limit=0)[source]#
Parameters:
  • file_name (str | Path) – The location of the log file to monitor.

  • queue (Queue) – The queue where log entries are put and to be consumed.

  • status (Context) – The status of the simulation (e.g. current time step).

  • stop_callback (Callable[[], None]) – A callback function to stop the simulation.

  • line_limit (int) – The number of lines to read before stopping the simulation. 0 means no limit.

on_created(event)[source]#

Process the log file when it is created.

Parameters:

event (DirCreatedEvent | FileCreatedEvent) – The file system event from watchdog.

Return type:

None

on_modified(event)[source]#

Process the log file when it changes.

Parameters:

event (FileModifiedEvent | DirModifiedEvent) – The file system event from watchdog.

Return type:

None

process()[source]#

Parse the complete lines added since the last call.

Stop at the termination record or after line_limit lines.

Return type:

None