Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reconsidering suggested use #26

Open
nsheff opened this issue Oct 26, 2023 · 2 comments
Open

reconsidering suggested use #26

nsheff opened this issue Oct 26, 2023 · 2 comments

Comments

@nsheff
Copy link
Member

nsheff commented Oct 26, 2023

right now the docs suggest adding this to the __init__.py for a logmuse-enabled package:

import logmuse
logmuse.init_logger(PACKAGE)

Ostensibly, this does thsi: "Now it will be set up with default parameters for your within-python-use. "

However, in my hands, this is making it so that for a package that does this, its logger is not inheriting the formatter from a root logger.

the example is, I'm trying to test bbconf interactively, like this:

from bbconf import BedBaseConf

import logging
import sys

def set_up_interactive_logger(package=None) -> logging.Logger:
    """Set up a logger for interactive testing"""
    _LOGGER = logging.getLogger(package)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    stream = logging.StreamHandler(sys.stdout)
    stream.setFormatter(formatter)
    stream.setLevel(logging.DEBUG)
    _LOGGER.addHandler(stream)
    _LOGGER.setLevel(logging.DEBUG)
    return _LOGGER

_LOGGER = set_up_interactive_logger()
_LOGGER.debug("Test log message")


bbc = BedBaseConf("../bedbase.org/config/bedbase.yaml")

So _LOGGER is a root logger. but when I instantiate BedBaseConf, then bbconf is correctly using this formatter, but the pipestat logger is ignoring it.

If I remove the call to logmuse. init_logger from pipestat.__init__.py, then it works correctly.

So I think the recommendation in the docs is actually breaking things and I'm not sure what the solution is.

@nsheff
Copy link
Member Author

nsheff commented Jan 29, 2024

@vreuter it would be useful to have your thoughts here if you have a minute

@simeoncarstens
Copy link

Sorry for the noise - I deleted my last comment because it turns out that the issue is elsewhere. Nevertheless, I think this might be related to what we are working on, namely redirecting stderr / stdout to a io.StringIO stream in our HTTP API That only works if we remove the call to init_logger() in looper.__init__.py and explicitly specify stream=sys.stderr in the call to logmuse.logger_via_cli().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants