mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-02 06:39:57 -06:00
44 lines
824 B
Python
44 lines
824 B
Python
# ❓ LoggingWorkflow
|
|
|
|
import logging
|
|
import time
|
|
|
|
from examples.logger.client import hatchet
|
|
from hatchet_sdk import Context, EmptyModel
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logging_workflow = hatchet.workflow(
|
|
name="LoggingWorkflow",
|
|
)
|
|
|
|
|
|
@logging_workflow.task()
|
|
def root_logger(input: EmptyModel, ctx: Context) -> dict[str, str]:
|
|
for i in range(12):
|
|
logger.info("executed step1 - {}".format(i))
|
|
logger.info({"step1": "step1"})
|
|
|
|
time.sleep(0.1)
|
|
|
|
return {"status": "success"}
|
|
|
|
|
|
# ‼️
|
|
|
|
# ❓ ContextLogger
|
|
|
|
|
|
@logging_workflow.task()
|
|
def context_logger(input: EmptyModel, ctx: Context) -> dict[str, str]:
|
|
for i in range(12):
|
|
ctx.log("executed step1 - {}".format(i))
|
|
ctx.log({"step1": "step1"})
|
|
|
|
time.sleep(0.1)
|
|
|
|
return {"status": "success"}
|
|
|
|
|
|
# ‼️
|