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

Remove Support for CEMENT_FRAMEWORK_LOGGING #639

Open
derks opened this issue Jul 5, 2022 · 4 comments
Open

Remove Support for CEMENT_FRAMEWORK_LOGGING #639

derks opened this issue Jul 5, 2022 · 4 comments

Comments

@derks
Copy link
Member

derks commented Jul 5, 2022

The env var CEMENT_FRAMEWORK_LOGGING was deprecated in favor of CEMENT_LOG in Cement 3.0.8. Support needs to be removed in 3.2.0:

Deprecation ID: 3.0.8-1

Ref:

@derks derks added this to the 3.2.0 Stable milestone Jul 5, 2022
@TomFreudenberg
Copy link
Contributor

Hi @derks

It is anoying to see that every time my tests are running. What do you suppose to do best until 3.2?

Image

Thanks for help
Tom

@derks
Copy link
Member Author

derks commented Feb 3, 2025

@TomFreudenberg I believe what you want is the following:

  • Set YourApp.Meta.framework_logging == False

The deprecration is triggered if two ways:

  • If you pass --debug option to a Cement App
  • If YourApp.Meta.framework_logging == True

If you do want framework logging still, you then would set the environment variable CEMENT_FRAMEWORK_LOGGING=1. I believe that will stop the deprecation warning.

@TomFreudenberg
Copy link
Contributor

@derks

class Fairy(App):
    """The Fairy primary application."""

    class Meta:
        # this app name
        label = 'fairy'

        framework_logging = False

does not work but running tests by:

CEMENT_LOG=0 make test

prevents the warning from cement but also disables all framework debugs.

OK for the moment, but should be improved I suggest.

@derks
Copy link
Member Author

derks commented Feb 4, 2025

@TomFreudenberg ah, yes ... CEMENT_LOG is what I meant... I think the problem is I am deprecating App.Meta.framework_logging after the processing of CEMENT_LOG (which is adding a backward-compat to set App.Meta.framework_logging.

https://github.com/datafolklabs/cement/blob/main/cement/core/foundation.py#L750-L775

        # enable framework logging from environment?
        if 'CEMENT_LOG' in os.environ.keys():
            val = os.environ.get('CEMENT_LOG')
            assert val in ['0', '1'], \
                f'Invalid value for CEMENT_LOG ({val}). Must be one of: 0, 1'
            if is_true(val):
                self._meta.framework_logging = True
            else:
                self._meta.framework_logging = False

        if 'CEMENT_FRAMEWORK_LOGGING' in os.environ.keys():
            deprecate('3.0.8-1')
            val = os.environ.get('CEMENT_FRAMEWORK_LOGGING')
            assert val in ['0', '1'], (
                f'Invalid value for CEMENT_FRAMEWORK_LOGGING ({val}). Must '
                f'be one of: 0, 1'
            )
            if is_true(val):
                self._meta.framework_logging = True
            else:
                self._meta.framework_logging = False

        # DEPRECATE: in v3.2.0, this needs to set os.environ if is True
        if self._meta.framework_logging is True:
            deprecate('3.0.8-2')
            os.environ['CEMENT_LOG_DEPRECATED_DEBUG_OPTION'] = '1'

I think we could move the 3.0.8-2 deprecation up first and that might help, but honestly it's probably time to sprint on 3.2.0 and cleanup these outstanding deprecations.

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

No branches or pull requests

2 participants