ditk.logging¶
LoggingTerminalHandler¶
-
class
ditk.logging.
LoggingTerminalHandler
(use_stdout: bool = False, level: Union[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: Optional[str] = None, delay: bool = False, **kwargs)[source]¶ -
__init__
(filename: str, mode: str = 'a', encoding: Optional[str] = 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.
-
property
file_path
¶ Unique path of the file.
-
try_init_root¶
getLogger¶
-
ditk.logging.
getLogger
(name: Optional[str] = None, level: Optional[Union[int, str]] = None, with_files: Optional[List[str]] = None) → logging.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.