Module: core.logger

Logger class for IPython’s logging facilities.

1 Class

class IPython.core.logger.Logger(home_dir: str, logfname: str = 'Logger.log', loghead: str = '', logmode: str = 'over')

Bases: object

A Logfile class with different policies for file creation

__init__(home_dir: str, logfname: str = 'Logger.log', loghead: str = '', logmode: str = 'over') None
close_log() None

Fully stop logging and close log file.

In order to start logging again, a new logstart() call needs to be made, possibly (though not necessarily) with a new filename, mode and other options.

log(line_mod: str, line_ori: str) None

Write the sources to a log.

Inputs:

  • line_mod: possibly modified input, such as the transformations made by input prefilters or input handlers of various kinds. This should always be valid Python.

  • line_ori: unmodified input line from the user. This is not necessarily valid Python.

log_write(data: str, kind: str = 'input') None

Write data to the log file, if active

logstart(logfname: str | None = None, loghead: str | None = None, logmode: str | None = None, log_output: bool = False, timestamp: bool = False, log_raw_input: bool = False) None

Generate a new log-file with a default header.

Raises RuntimeError if the log has already been started

logstate() None

Print a status message about the logger.

logstop() None

Fully stop logging and close log file.

In order to start logging again, a new logstart() call needs to be made, possibly (though not necessarily) with a new filename, mode and other options.

switch_log(val: bool) None

Switch logging on/off. val should be ONLY a boolean.