Skip to content

How to Access Contextualized Values Within do_something() Function? #1179

Open
@tstrg

Description

@tstrg

Hello,

I'm trying to understand how to read contextualized values within the do_something() function when using the logger.contextualize() method. Here is an example of my code:

from loguru import logger

task_id = "12345"

def do_something():
    # How can I access the contextualized 'task' value here?
    logger.info("Doing something")

with logger.contextualize(task=task_id):
    do_something()
    logger.info("End of task")

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions