How do y'all deal with logging when testing outsid...
# ask-community
m
How do y'all deal with logging when testing outside of a flow/task? Do you do something like this?
Copy code
def get_logger() -> Logger:
    try:
        return prefect.get_run_logger()
    except RuntimeError:
        return logging.getLogger(__name__)
m
Thanks Ben, that's helpful
🙌 1
n
in case its helpful, there's also a util for this
Copy code
In [1]: from prefect import flow, get_run_logger

In [2]: from prefect.logging.loggers import disable_run_logger

In [3]: @flow
   ...: def foo():
   ...:     get_run_logger().info("cant see me")
   ...:     return "foo"
   ...:

In [4]: with disable_run_logger():
   ...:     r = foo.fn()
   ...:

In [5]: assert r =="foo"
m
🤙