Hi. I’m testing a dagster-decorated function (`@gr...
# ask-community
d
Hi. I’m testing a dagster-decorated function (
@graph
) in an exception case, and as such I’d like to disable dagster’s logging as it makes a mess of the test’s logging output. However, calling
getLogger('dagster').setLevel(…
before the test does not seem to work - checking the logger after the test shows that it’s been force-reset in the interim. How can one actually disable the logging for the duration of a text execution?
🤖 1
s
thoughts on this @owen?
o
hi @Duncan! This worked for me (you can set the level of
dagster.builtin
, just not
dagster
):
Copy code
import logging
from dagster import op, get_dagster_logger, build_op_context


@op
def foo(context):
    get_dagster_logger().debug("hi")
    return 1


def test_foo():
    dagster_logger = logging.getLogger("dagster.builtin")
    dagster_logger.setLevel("ERROR")
    foo(build_op_context())
    assert False
d
@owen Thanks ❤️ I will give that a whirl