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

Can't see any debug #626

Open
itJunky opened this issue Jun 14, 2022 · 4 comments
Open

Can't see any debug #626

itJunky opened this issue Jun 14, 2022 · 4 comments

Comments

@itJunky
Copy link

itJunky commented Jun 14, 2022

Want to fix plugin for hiding memberlist https://github.com/haliphax/flaskbb-plugin-private-memberlist.
Trying to begin with output some debug by adding any logger or print into __init__,py of plugin:

    @app.before_request
    def check_logined_for_memberlist():
        'Check authentication before request is handled.'

        print(f'Текущий ендпоинт: {request.endpoint}')
        logging.config.dictConfig(app.config["LOG_DEFAULT_CONF"])
        # logging.basicConfig(filename='/tmp/LOG.log', encoding='utf-8')
        # logging.basicConfig(filename='LOG.log', encoding='utf-8', level=logging.DEBUG)
        logging.critical(f'Текущий ендпоинт: {request.endpoint}')

But nothing printed in logs dir and any other tried paths.
How can i see value of request.endpoint?

@itJunky
Copy link
Author

itJunky commented Jun 15, 2022

May be i need exception?

@itJunky
Copy link
Author

itJunky commented Jun 15, 2022

Wow shity magic (
Insert FLASK_ENV=development at run command and logger begins working correctly...

@itJunky
Copy link
Author

itJunky commented Jun 15, 2022

But i see only logging message inserted into app.py after:

    @app.before_request
    def update_lastseen():

And see 0 message when insert same logging string into plugin __init__.py
How i can debug plugins correctly?

@itJunky
Copy link
Author

itJunky commented Jun 15, 2022

What wrong with memberlist plugin? App restarted when i save file from plugin but nothing else.
When i insert code from plugin

def configure_before_handlers(app):
    """Configures the before request handlers."""

    endpoints = (
        'forum.memberlist',
        'forum.search',
        'user.profile',
        'user.view_all_topics',
        'user.view_all_posts',
    )

    @app.before_request
    def update_lastseen():
        """Updates `lastseen` before every reguest if the user is
        authenticated."""
        logging.critical(f'Текущий ендпоинт в @app.before_request: {request.endpoint}')
        if current_user.is_authenticated:
            current_user.lastseen = time_utcnow()
            db.session.add(current_user)
            db.session.commit()

        if (request.endpoint in endpoints
                and not current_user.is_authenticated):
            return app.login_manager.unauthorized()

into app.py it is work correctly and redirects to login form when i click to memberlist link. But this is not plugin.

How can i use plugin https://github.com/haliphax/flaskbb-plugin-private-memberlist correctly?

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

1 participant