sk4la12/20/2020, 7:24 PM
I tried to do something like this in order to do the equivalent within Dagster:
# Prefect example import logging import prefect @task def call_a_foreign_function(): log_from_a_foreign_function() def log_from_a_foreign_function(): logger = prefect.context.get("logger", logging.getLogger("default_logger_if_no_prefect_context_is_found")) <http://logger.info|logger.info>("It works! I can still log to the main logger even if I'm a foreign function!")
Sadly, it does not seem to work, I’m only able to log to the Dagit console (not the UI). Does Dagster have a cool way to log to the UI from “outside” of solids ?
# Dagster equivalent import logging from dagster import solid @solid def call_a_foreign_function(): log_from_a_foreign_function() def log_from_a_foreign_function(): logging.getLoggerClass()("dagster").warning("Can I speak to the UI like this?") logging.getLogger("dagster").warning("Can I speak to the UI like this?")
daniel12/20/2020, 7:28 PM
sk4la12/20/2020, 7:33 PM
object to every foreign function, is there another way to “retrieve the logger from the other side” ?
daniel12/20/2020, 7:58 PM
sk4la12/20/2020, 8:00 PM
Noah K12/21/2020, 12:10 AM
max12/21/2020, 7:25 PM
and log that way
) that will show up in dagit, just not in the structured log viewer
sk4la01/12/2021, 7:43 PM
module). The main benefit I see (based on my own experience) is the ability to “catch” the logger from ouside of Dagster without the need to pass around the context object.