Hi chat what's a good way to handle logging from f...
# ask-community
j
Hi chat what's a good way to handle logging from functions inside tasks? By that I mean, I would like to avoid print statements. I've been using
log_prints=True
. Sometimes i pass the logger into the function.
Copy code
from prefect import flow, task
from prefect.logging import get_run_logger

@task(log_prints=True)
def task_one():
    logger = get_run_logger()
    step_one()
    step_two()


def step_one():
  print("Hello") 

def step_two():
  print("World")
n
hi @juana - id say it depends, theres no one right way. passing the logger object is valid. using
print
and log_prints is also valid. what problems/friction are you encountering with your current strategy?