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.terminal.interactiveshell.TerminalInteractiveShell
) – The activeipython
Shell
, 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
INPUT
log level and registeringIPythonLogger.log
to run on thepost-execute
event.- Parameters:
ip (
ipython
Shell
) – The activeipython
Shell
, perhaps the one returned byIPython.get_ipython()
.