ditk.logging
LoggingTerminalHandler
- class ditk.logging.LoggingTerminalHandler(use_stdout: bool = False, level: int | str = 0)[source]
- Overview:
A handler customized in
ditk
.When
DISABLE_RICH
environment variable is set to non-empty, log will be printed to ordinaryStreamHandler
, otherwiserich.logging.RichHandler
will be used.
LoggingFileHandler
- class ditk.logging.LoggingFileHandler(filename: str, mode: str = 'a', encoding: str | None = None, delay: bool = False, **kwargs)[source]
- __init__(filename: str, mode: str = 'a', encoding: str | None = None, delay: bool = False, **kwargs) None [source]
Open the specified file and use it as the stream for logging.
- emit(record)
Emit a record.
If the stream was not opened because ‘delay’ was specified in the constructor, open it before calling the superclass’s emit.
If stream is not open, current mode is ‘w’ and _closed=True, record will not be emitted (see Issue #42378).
- property file_path: str
Unique path of the file.
try_init_root
getLogger
- ditk.logging.getLogger(name: str | None = None, level: int | str | None = None, with_files: List[str] | None = None) Logger [source]
- Overview:
Get
logging.Logger
object, with terminal output and file output.
- Parameters:
name – Name of logger.
level – Logging level of the loggers.
with_files – The files going to output.
- Return logger:
Logger created.