Logging in Task Scripts¶
Overview¶
This page outlines our guidelines for logging in task scripts.
Guidelines¶
Use log messages to inform the user of non-critical problems found in the data, like optional sections which are missing.
Logging a warning is reserved for cases where the data is not essential to the use case.
Logging usage¶
First the logger must be set up in
main.pyby callingtask_script_utilsworkflow_logging.setup_ts_log_handler(context.get_logger(), "main")in themainfunction.In other modules where you want to log, you must include the following at the top of the module:
import logging
logger = logging.getLogger("main." + __name__)
To log a warning you can then simply call
logger.warning("This is a warning message")