Skip to content

child process (spawn context): set parent logger globally for all modules #818

@PakitoSec

Description

@PakitoSec

Thanks for this awesome library.

I would like to set the parent logger globally in a child process (spawn method) so I don't have to do that within all my modules like I saw in this example: loguru multiprocess.

The only way I found is by using the code below but I think this is not recommended since _core is not in the public api:

Module A:
from loguru import logger
...
    def entrypoint_child_process(self, logger_):
        logger._core = logger_._core

Module B:
from loguru import logger
...
    def child_job(self):
        logger.info("test")

What could be the solution in order to set the arg logger_ globally in the child process so I don't have to do the trick describe in your documentation in each module ?

UPDATE:
Maybe this could be accepted ?

    logger.__dict__ = logger_.__dict__.copy()

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureRequest for adding a new feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions