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

[Bug] OpenBB Platform hijacks default logger #6680

Open
ncimino opened this issue Sep 19, 2024 · 3 comments · May be fixed by #6681
Open

[Bug] OpenBB Platform hijacks default logger #6680

ncimino opened this issue Sep 19, 2024 · 3 comments · May be fixed by #6681
Labels
bug Fix bug

Comments

@ncimino
Copy link

ncimino commented Sep 19, 2024

Describe the bug
By importing openbb the default logger is manipulated impacting host applications.

To Reproduce
Run this code:

import logging
logging.basicConfig(level=logging.INFO)
logging.info("This message is shown")
import openbb
logging.info("This message is hidden")

Notice: That the host application messages which are printed after importing openbb no longer function the same.

At the very least it would be nice to be able to disable this behavior with a user/system setting so that the host application can control logging. Yes the application can override, but because this happens when openbb is imported it can happen at any time while the application is running. This design effectively forces the user to import openbb at a controlled location to then override these settings which is of course not ideal.

Desktop (please complete the following information):

  • OS: Mac affects all OSes
  • Python version 3.11 affects all versions

Additional context
I believe this is due to the LoggingService changing the default logging configuration:
https://github.com/OpenBB-finance/OpenBB/blob/develop/openbb_platform/core/openbb_core/app/logs/logging_service.py#L122-L128

        logging.basicConfig(
            level=self._logging_settings.verbosity,
            format=FormatterWithExceptions.LOGFORMAT,
            datefmt=FormatterWithExceptions.DATEFORMAT,
            handlers=[],
            force=True,
        )
@deeleeramone
Copy link
Contributor

deeleeramone commented Sep 19, 2024

Hi there,

I don't believe this is a bug. Warnings and errors are handled internally by the application and passed forward. The OpenBB environment can be configured to display console messages and/or tracebacks.

You can enable warnings verbosity in the file, ~/.openbb_platform/user_settings.json

{
    "preferences": {
        "show_warnings": false,
    }
}

Debug mode is enabled with an environment variable. This passes through the complete Exception with traceback.

OPENBB_DEBUG_MODE=true

@montezdesousa, do you have anything to add that can clarify?

@deeleeramone deeleeramone added the bug Fix bug label Sep 19, 2024
@ncimino
Copy link
Author

ncimino commented Sep 20, 2024

Thanks @deeleeramone

I am still a little concerned though, because just importing a package should not alter the behavior of my app which is what’s happening.

@piiq
Copy link
Contributor

piiq commented Sep 20, 2024

Hey @ncimino 👋 Thanks for bringing this to our attention. While we look into this ourselves if you have any suggestions on how to change the LoggingService, they would be very appreciated.

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

Successfully merging a pull request may close this issue.

3 participants