Logging
Module: cutoop.log
.
In principle, we recommend Python’s official logging package for logging. This module contains utilities for logging setup.
functionsetup_logging(log_mode: str, debug = False, logfile: str | None = None, json = True, delay = True)
Setup a simple logging for Python’s official logging
package.
Parameters:
- log_mode –
file
for only logging to file, terminal for only logging to terminal, otherwise both are taken. - debug – whether set loglevel to DEBUG (default is INFO)
- logfile – specify logging filename
- json – whether output json format log, whose file name is
logfile + ".jl"
. - delay – See FileHandler
Usage:
# only logging to terminal, enabling debug level logging.
setup_logging("terminal", debug=True)
# only logging to runtime.log file and runtime.log.jl (json log)
setup_logging("file", logfile="runtime.log")
# logging to terminal and file without json
setup_logging("both", logfile="runtime.log", json=false)