Hello all, I am new to dagsster. I have a quick qn...
# ask-community
n
Hello all, I am new to dagsster. I have a quick qn regarding logging. How do I log within a custom IO manager? when I try to use OutputContext it says, there is no logger available. this is a sample io manager I have
Copy code
class HubspotIOManager(IOManager):
    def __init__(self, token: str) -> None:
        
        pass

    def handle_output(self, context: OutputContext, obj: pd.DataFrame):
        # Skip handling if the output is None
        if obj is None:
            return

        
        obj_name = context.asset_key.to_python_identifier()

        # do stuff.
  

        # Recording metadata from an I/O manager:
        # <https://docs.dagster.io/concepts/io-management/io-managers#recording-metadata-from-an-io-manager>
        context.add_output_metadata({ "table_name": table_name})

    def load_input(self, context: InputContext):
        # upstream_output.asset_key is the asset key given to the Out that we're loading for
        pass
o
hi @Nidhin Nandhakumar !
<http://context.log.info|context.log.info>("hi")
inside handle_output/load_input should work -- do you mind sharing the full stack trace?
n
thanks. I think I used context.logger instead of context.log. my bad
another question. if I want to log inside a separate class resource. what is the recommended method? eg: like in this resource https://github.com/dagster-io/dagster/blob/1.2.4/examples/project_fully_featured/project_fully_featured/resources/hn_resource.py
o
get_dagster_logger().info("hi")
is probably the easiest method
👍 1
(
from dagster import get_dagster_logger
)
n
nice. thankyou