Opened 14 years ago

Closed 11 years ago

#13320 closed Uncategorized (wontfix)

loaddata and syncdb should use the python logging

Reported by: chtito Owned by: nobody
Component: Uncategorized Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The commands that use a verbosity flag (loaddata and syncdb) should use the built-in logging facility of Python instead of if verbosity > x: print "...".

The rationale is that it makes testing the output of commands much easier. The code is cleaner. Less print commands to translate to Py3k.
And no difference for the end user.

Change History (3)

comment:1 by Russell Keith-Magee, 14 years ago

Resolution: duplicate
Status: newclosed

I'm going to close this as a dupe of #12012. A built-in logging framework is something we want to introduce across-the-board for Django; not just in one or two places.

comment:2 by anonymous, 11 years ago

Easy pickings: unset
Resolution: duplicate
Severity: Normal
Status: closednew
Type: Uncategorized
UI/UX: unset
Version: 1.1

Sorry to bother, but since #12012 is closed and syncdb still uses self.stdout.write, I believe this ticket should be re-opened.

If using stdout.write was intentional decision, please write a short clarification (so those who wonder won't re-ask and re-open this) and close this ticket.

comment:3 by Luke Plant, 11 years ago

Resolution: wontfix
Status: newclosed

I don't know the original rationale for using stdout/stderr, but I can think of one: a Django project will typically have logging configuration that is suitable for an unattended process i.e. web server, or cronjob. This config is applied when settings are imported, and may well configure everything to go to an external service e.g. Sentry or a logfile. If logging was used for management commands, then it would be extremely easy for them to end up printing nothing to the console.

There may be holes in that explanation, I'm not sure - there might be a relatively easy way to use logging and still ensure that output was visible.

However, is it worth the effort? What actual advantages are there to using logging? Management commands no longer use 'print' but 'self.stdout', which allows output to be tested, so the original rationale doesn't stand.

Closing WONTFIX on that basis.

Note: See TracTickets for help on using tickets.
Back to Top