ipython_log.py

This module modifies an ipython shell to log inputs, outputs, and tracebacks to a custom logger.input level. The INPUT level is lower than the DEBUG level to avoid a terminal echo in debug mode.

class hutch_python.ipython_log.IPythonLogger(ipython)

Class that logs the most recent inputs, outputs, and exceptions at the custom INPUT level.

Parameters

ipython (ipython Shell) – The active ipython Shell, perhaps the one returned by IPython.get_ipython().

log()

Logs the most recent inputs, outputs and exceptions.

  • Always logs the most recent input

  • If this input has a corresponding output, log the output

  • If there has been an error in the interactive session since the last call to log, log the error

hutch_python.ipython_log.load_ipython_extension(ipython)

Initialize the IPythonLogger.

This involves adding the INPUT log level and registering IPythonLogger.log to run on the post-execute event.

Parameters

ip (ipython Shell) – The active ipython Shell, perhaps the one returned by IPython.get_ipython().