setup_console_logging

Documentation for eth_defi.coloured_logging.setup_console_logging function.

setup_console_logging(default_log_level='warning', *, simplified_logging=False, log_file=None, std_out_log_level=None, only_log_file=False, clear_log_file=True, coloured_threads=False, autodetect_docker_log=True, stream=None)

Set up coloured log output.

  • Helper function to have nicer logging output in tutorial scripts.

  • Tune down some noisy dependency library logging.

Parameters
  • default_log_level (Union[str, int]) – Default logging level if LOG_LEVEL is not set.

  • simplified_logging (bool) – Do not add module and thread fields when True.

  • log_file (Optional[Union[str, pathlib.Path]]) – Output both console and this log file.

  • std_out_log_level (Optional[Union[str, int]]) – Override the console logging level.

  • only_log_file (bool) – Do not install a console handler when True.

  • clear_log_file (bool) – Truncate the log file before writing when True.

  • coloured_threads (bool) – When True, each thread name in the log output gets a unique ANSI colour so interleaved parallel logs are easy to follow visually.

  • autodetect_docker_log (bool) – Enable coloured Rich output inside Docker even when stderr is not a TTY. Enabled by default because Docker Compose preserves ANSI escape sequences in logs -f.

  • stream (Optional[TextIO]) – Console stream that receives log output. Defaults to sys.stderr.

Returns

Root logger.

Return type

logging.Logger