-
Notifications
You must be signed in to change notification settings - Fork 268
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
Enable Color-Coded Logs for SpectacularAPIView and Improve Logging Customization via Django Logger #1292
Comments
I just tried this out in my local codebase. @tfranzel Let me know your thoughts on this and I would try to draft a PR based on that. |
Hi, there is no color option for the views because those messages usually end up in the logs and are harder to read then. Line numbers are not enabled by default because that is an expensive operation. Its hacky but you can import the generator instance somewhere in your code and enable it by hand since its a global state.
Nobody ever asked for color in the logs of the views in all this time. I do not think it is worth adding options and complicating the view for this rare use-case. For development, if you want nice logs with useful traces, use the I would entertain the idea of adding logger in addition to |
Hi,
I don’t think we can add a logger in addition to Could we add an extra setting in For colored logs, perhaps we can enable them by default when I understand this might not be directly related to the core functionality of this package, and adding these options to the settings could be seen as irrelevant. These are just some ideas I wanted to share. |
I just read through thread #866 and I’m relatively new to this codebase.
My Issue
When I call the
drf_spectacular.views.SpectacularAPIView
view, the error and warning messages are logged in my console. I wanted to enable color coding for these logs.I found that the
drf_spectacular.drainage.GeneratorStats.enable_color
method enables this option. However, it’s not enabled by default, and I also noticed that this function is only called in thespectacular
management command. How can I enable color coding for console logs outside of this context?Idea to Improve Customizability for Users
Would it be possible to use the Django logger to emit logs in the
drf_spectacular.drainage.GeneratorStats.emit
method? This would allow users to customize log formats via Django's logging settings.The text was updated successfully, but these errors were encountered: