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

setup_logging does not use LOG_EXTRA in all cases #3025

Open
1 task done
ozancaglayan opened this issue Jan 6, 2025 · 0 comments
Open
1 task done

setup_logging does not use LOG_EXTRA in all cases #3025

ozancaglayan opened this issue Jan 6, 2025 · 0 comments
Labels

Comments

@ozancaglayan
Copy link

ozancaglayan commented Jan 6, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Since >= 24.6 where logging was overhauled, it is nearly impossible to recover the pre-24.6 behaviour for logging if LogRecord has additional fields. They are getting logged as extra lines when mode is debug. I managed to make it work correctly for non-debug mode.

Tried setting SANIC_LOG_EXTRA=false , doesn't seem to work as this value seems to be sometimes read but also is written by Sanic itself in sanic/logging/setup.py.

I then noticed that setup_logging has a log_extra param which is by default set using the deployment mode. But in some cases depending on how the service is run, the third parameter is also passed.

sanic/worker/serve.py:        setup_logging(
sanic/worker/serve.py-            app.state.is_debug, app.config.NO_COLOR, app.config.LOG_EXTRA
sanic/worker/serve.py-        )
sanic/worker/serve.py-

sanic/app.py-        details: https://asgi.readthedocs.io/en/latest
sanic/app.py-        """
sanic/app.py-        if scope["type"] == "lifespan":
sanic/app.py:            setup_logging(self.state.is_debug, self.config.NO_COLOR)

I think the latter should also obey the self.config.NO_COLOR parameter for consistency.

Code snippet

No response

Expected Behavior

I expect a clear way of disabling this LOG_EXTRA feature either from the environment or through other mechanisms.

How do you run Sanic?

Sanic CLI

Operating System

Linux

Sanic Version

24.12

Additional context

No response

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

No branches or pull requests

1 participant