Hello! I have one more question about logging. I u...
# ask-community
k
Hello! I have one more question about logging. I use tasks as a containers method for my code pulled from repo. This is example:
Copy code
def cut(app=None):
    app.url_cutting()


@flow(retries=2, retry_delay_seconds=1500)
def url_cut_flow():
    """
    Url cutting.
    """
    from DSTools_lite.dstools_lite.src.application.LAL_calculations_oset import LALCalculator
    
    app = LALCalculator()
    cut(app=app)


if __name__ == "__main__":
    url_cut_flow()
method app.url_cutting() has it's own loggings inside, is there any possibility to print these logs in Prefect UI while running flow? Thanks!
j
Hey Kacper! I believe you are looking for
PREFECT_LOGGING_EXTRA_LOGGERS
environment var setting: • https://docs.prefect.io/latest/guides/logs/#including-logs-from-other-libraries I usually just pass Prefect get_run_logger everywhere, but I don't know best practice.
upvote 1
n
what Jack said, if you want to see an example, where the module that i want to capture logs from is called
marvin
https://github.com/PrefectHQ/marvin-recipes/blob/main/prefect.yaml#L27-L38
k
Thanks guys! Would it help to set
PREFECT_LOGGING_EXTRA_LOGGERS
while my repo is not python library? Should I just point to repo root?
@Jack P could you show some example where are you passing
get_run_logger
in code? Is it just like in Docs pages?
j
Copy code
from logging import Logger

from prefect import flow, get_run_logger

from DSTools_lite.dstools_lite.src.application.LAL_calculations_oset import (
    LALCalculator,
)


def cut(logger: Logger, app=None):
    <http://logger.info|logger.info>("hi from function `cut`")

    app.url_cutting()
    
    <http://logger.info|logger.info>("bye from function `cut`")


@flow(retries=2, retry_delay_seconds=1500)
def url_cut_flow():
    """
    Url cutting.
    """
    logger = get_run_logger()

    <http://logger.info|logger.info>("starting")

    app = LALCalculator()
    cut(logger=logger, app=app)

    <http://logger.info|logger.info>("finished")


if __name__ == "__main__":
    url_cut_flow()
I usually do this if it's not a flow or task, just pass as parameter
1