Logging¶
Spiff provides several loggers:
the
spiff.workflowlogger, which emits messages when actions are taken on a workflowthe
spiff.tasklogger, which emits messages when tasks change state
Records emitted at the INFO level, with addtional attributes available for debugging if the level is lower.
Log entries emitted by the spiff.workflow logger contain the following extra atributes:
workflow_spec: the name of the spec for this workflowcompleted: whether the workflow has completedsuccess: the value of thesuccessattribute
If the log level is less than 20, records include the following extra attribute:
tasks: a list of the task ids in the workflow
Log entries emitted by the spiff.task logger contain the following extra attributes:
workflow_spec: the name of the spec for this workflowtask_spec: the name of the spec for this tasktask_id: the ID of the task)task_type: the name of the task’s spec’s classstate: the name of the tasksTaskStatelast_state_chsnge: the timestamp at which the state change was madeelapsed: the elapsed time since the previous state transitionparent: the id of the task’s parent
If the log level is less than 20, records include the following extra attributes:
datathe task datainternal_data: the task internal data
Log entries containing task data and internal data can be quite large, so use with caution!
In our command line UI (cli/subcommands.py), we’ve added a few of these extra attributes to the log records:
task_logger = logging.getLogger('spiff.task')
task_handler = logging.StreamHandler()
task_handler.setFormatter(logging.Formatter('%(asctime)s [%(name)s:%(levelname)s] (%(workflow_spec)s:%(task_spec)s) %(message)s'))
task_logger.addHandler(task_handler)
wf_logger = logging.getLogger('spiff.workflow')
wf_handler = logging.StreamHandler()
wf_handler.setFormatter(logging.Formatter('%(asctime)s [%(name)s:%(levelname)s] (%(workflow_spec)s) %(message)s'))
wf_logger.addHandler(wf_handler)