logging
ensembl.utils.logging
¶
Easy initialisation functionality to set an event logging system.
Examples:
>>> import logging, pathlib
>>> from ensembl.utils.logging import init_logging
>>> logfile = pathlib.Path("test.log")
>>> init_logging("INFO", logfile, "DEBUG")
>>> logging.info("This message is written in both stderr and the log file")
>>> logging.debug("This message is only written in the log file")
LogLevel = Union[int, str]
module-attribute
¶
init_logging(log_level='WARNING', log_file=None, log_file_level='DEBUG', msg_format='%(asctime)s\t%(levelname)s\t%(message)s', date_format='%Y-%m-%d_%H:%M:%S')
¶
Initialises the logging system.
By default, all the log messages corresponding to log_level
(and above) will be printed in the
standard error. If log_file
is provided, all messages of log_file_level
level (and above) will
be written into the provided file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_level
|
LogLevel
|
Minimum logging level for the standard error. |
'WARNING'
|
log_file
|
Optional[StrPath]
|
Logging file where to write logging messages besides the standard error. |
None
|
log_file_level
|
LogLevel
|
Minimum logging level for the logging file. |
'DEBUG'
|
msg_format
|
str
|
A format string for the logged output as a whole. More information: https://docs.python.org/3/library/logging.html#logrecord-attributes |
'%(asctime)s\t%(levelname)s\t%(message)s'
|
date_format
|
str
|
A format string for the date/time portion of the logged output. More information: https://docs.python.org/3/library/logging.html#logging.Formatter.formatTime |
'%Y-%m-%d_%H:%M:%S'
|
Source code in src/ensembl/utils/logging.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
init_logging_with_args(args)
¶
Processes the Namespace object provided to call init_logging()
with the correct arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args
|
Namespace
|
Namespace populated by an argument parser. |
required |
Source code in src/ensembl/utils/logging.py
84 85 86 87 88 89 90 91 92 93 |
|