On May 24, 10:37 am, Russell Keith-Magee <freakboy3...@gmail.com> wrote: > > We will be sprinting at the conference on Thursday and Friday. If you > have a detailed proposal that would benefit from some round-table > discussion while several core developers are in the same room, please > post your proposal and we'll try to discuss it. Alternatively, if you > wait until early next week, life should return to relative normality.
Now that Django 1.2.1 has been released, I'd like to raise again the question of introducing logging into Django, which was mooted by Simon Willison (http://code.djangoproject.com/wiki/LoggingProposal) for inclusion in 1.2, but then shelved for lack of time/other priorities. I don't know if it's too early to bring this up for 1.3, but the Python changes relating to dictionary-based configuration have been added to Python (for inclusion in 2.7 and 3.2) and with a standalone implementation (dictconfig) which can be co-opted for use in Django with earlier versions of Python. I've created a logging branch which mirrors Django trunk just after the 1.2 release. The branch incorporates the dictconfig module and also allows a simple mechanism for initialising logging (using dictconfig or any other mechanism) via settings.py (with no need to worry about multiple imports of settings.py). As an illustration, I've added logging statements in some Django modules (e.g. request handling, app loading, SQL execution) which don't do any actual logging by default, but which can be turned on by a suitable logging configuration. The logging branch is available on Launchpad., which uses the Bazaar DVCS. I know that Bazaar isn't everyone's favourite, but it should be easy enough to import this into Mercurial or Git when the time comes. The branch is at https://code.launchpad.net/~vinay-sajip/django/logging/ This will allow anyone to review the changes made to Django to incorporate logging. These are fairly small in scope: django/conf/__init__.py (added hooks for bootstrap one-off operations during Django initialisation, to be used for e.g. logging configuration) django/db/models/loading.py (added hooks for running user-defined code before and after app/model loading operations) django/utils/log.py (new file to hold Django logging-specific code, based on Simon Willison's version mentioned in ticket #12012). django/utils/dictconfig.py (new file, holding code to allow logging configuration via dicts in a way compatible with Python 2.7, 3.2 and usable with older Python versions). In addition, logging statements have been added to: django/db/models/loading.py (app/model loading) django/core/handlers/base.py (exception handling, including uncaught exceptions) django/db/backends/util.py (SQL statement execution) django/core/handlers/wsgi.py (Unicode exception during request handling) Overall the changes are fairly modest and should be fairly easy to review. Basic diffs to show what was added: http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/53 - Added callback hooks http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/55 - Added log module reference http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/56 - Added log module itself http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/55 - Removed log module reference (as not needed) http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/61 - Added dictconfig.py and changed code to use it http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/62 - Added useful default to configuration http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/63 - Added logging to app loading http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/65 - Added logging for SQL and uncaught exceptions in request handling http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/67 - Added some more logging to request handling code http://bazaar.launchpad.net/~vinay-sajip/django/logging/revision/69 - Added more logging to WSGI handler There's also a simple test project which you can use to play with these changes. This is available at https://code.launchpad.net/~vinay-sajip/+junk/django-logtest This is a vanilla 1.2-generated project which has changes only to settings.py. These illustrate how to initialise logging, configure listeners for class_prepared (as an example), and how to configure logging to generate output from the logging statements added to Django. I'd like to get some feedback on these changes, which are intended to make it as easy as possible to introduce logging into Django itself as well as configure logging with a Django site both for internal Django operations as well as contrib apps and other, third-party Django apps. Since many of the core team will be at DjangoCon.eu, hopefully there will be a chance while all are together to discuss the proposal about logging. As well as feedback on the general approach I've taken, I'm also interested in getting feedback as to where you think logging statements should be added in Django itself. For example, django.contrib.auth and django.contrib.admin would appear to be good candidates. I hope to garner suggestions for other areas - perhaps security-related, such as CSRF violations. Looking forward to that feedback, Vinay Sajip -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.