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
INPUTlevel.- Parameters
ipython (
IPython.terminal.interactiveshell.TerminalInteractiveShell) – The activeipythonShell, perhaps the one returned byIPython.get_ipython().
- ipython_in¶
The IPython user input list.
- Type
list of str
- prev_err_value¶
The last exception value that was logged. Used for exception deduplication.
- Type
Exception or None
- line_in_progress¶
True if a line is currently in the process of being evaluated.
- Type
bool
- log_exception(line_input='[n/a]')¶
Logs the most recent unhandled exception.
- log_output(result)¶
Logs the most recent output by way of the ‘post_run_cell’ hook.
- log_user_input(info)¶
Logs the most recent input by way of the ‘pre_run_cell’ hook.
- hutch_python.ipython_log.load_ipython_extension(ipython)¶
Initialize the
IPythonLogger.This involves adding the
INPUTlog level and registeringIPythonLogger.logto run on thepost-executeevent.- Parameters
ip (
ipythonShell) – The activeipythonShell, perhaps the one returned byIPython.get_ipython().