task_script_utils.workflow_logging module#
- map_ts_log_level(log_level_name: str) str[source]#
Convert Python’s logging levels to TetraScience log levels
- Parameters:
logging_level_name (str) – “WARNING”, etc.)
- Returns:
ts_log_level_name (str) - TetraScience log level string
- class TSLogFormatter[source]#
Bases:
FormatterLog formatter to convert python logs into the TetraScience format
- format(record)[source]#
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.
- class TSLogHandler(external_logger: object)[source]#
Bases:
StreamHandlerA log handler to redirect Python’s logs to an external logger function
- setup_ts_log_handler(external_logger: object, logger_scope: str = None) Logger[source]#
Set up a handler to send Python logs to the TetraScience workflow logger
After setting up this log handler, any logger created within the same logging hierarchy will have its logs sent to the external logger (see logging.getLogger docs for more on logging heirarchy).
- Parameters:
external_logger (object) – external_logger.log(record) will be called with a record formatted as a TetraScience log record.
logger_scope (str) - the name passed to logging.getLogger(logger_scope) – which defines the heirarchy of logs handled by the external logger.