ftag.utils.logging#
Configuration for logger of atlas-ftag-tools.
Attributes#
Classes#
Logging Formatter to add colours and count warning / errors using implementation |
Functions#
|
Get logging levels with string key. |
|
Initialise. |
|
Setting log level. |
Module Contents#
- class ftag.utils.logging.CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)#
Bases:
logging.Formatter
Logging Formatter to add colours and count warning / errors using implementation from https://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output.
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.
Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting,
str.format()
({}
) formatting orstring.Template
formatting in your format string.Changed in version 3.2: Added the
style
parameter.- grey = '\x1b[38;21m'#
- yellow = '\x1b[33;21m'#
- green = '\x1b[32;21m'#
- red = '\x1b[31;21m'#
- bold_red = '\x1b[31;1m'#
- reset = '\x1b[0m'#
- debugformat = '%(asctime)s - %(levelname)s:%(name)s: %(message)s (%(filename)s:%(lineno)d)'#
- date_format = '%(levelname)s:%(name)s: %(message)s'#
- formats: ClassVar#
- format(record)#
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- ftag.utils.logging.get_log_level(level: str)#
Get logging levels with string key.
- Parameters:
level (str) – Log level as string.
- Returns:
logging object with log level info
- Return type:
logging level
- Raises:
ValueError – If non-valid option is given
- ftag.utils.logging.initialise_logger(log_level: str | None = None)#
Initialise.
- Parameters:
log_level (str, optional) – Logging level defining the verbose level. Accepted values are: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET, by default None If the log_level is not set, it will be set to info
- Returns:
logger object with new level set
- Return type:
logger
- ftag.utils.logging.set_log_level(tools_logger, log_level: str)#
Setting log level.
- Parameters:
tools_logger (logger) – logger object
log_level (str) – Logging level corresponding CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
- ftag.utils.logging.logger#