Code

Opened 4 years ago

Closed 17 months 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.

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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 Changed 17 months ago by anonymous

  • Easy pickings unset
  • Resolution duplicate deleted
  • Severity set to Normal
  • Status changed from closed to new
  • Type set to Uncategorized
  • UI/UX unset
  • Version 1.1 deleted

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 Changed 17 months ago by lukeplant

  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.