Hello Christian,

I don't have an exact answer for you but there's open tickets about making 
management
commands use logging instead of custom output wrappers that might interest 
you.

Simon

[0] https://code.djangoproject.com/ticket/21429
[1] https://code.djangoproject.com/ticket/27877

Le samedi 28 septembre 2019 19:13:01 UTC+2, Christian González a écrit :
>
> Hi, 
>
> i just stumbled upon logging in management commands I saw that there is 
> an own system of logging. 
>
> When creating custom mgmt cmds, you have to write logging output to 
>
>     if options["verbosity"] >= 2: 
>         sys.stdout.write(message) 
>
> this is a little inconvenient, and much less DRY as e.g. 
>
>     logger.info(message) 
>
> But logger does not really work as intended in commands. 
>
> Was this a good choice? Yes, log levels can be changed using settings.py. 
>
> But: wouldn't it be convenient to use the system logger for that too in 
> Django? 
>
>
> My background is: I have made a plugin system, and I would have to add 
> the "verbosity" parameter to every plugin hook that is ought to print 
> out some logging strings. It would be a lot easier to use logger.warning 
> e.g. for that. 
>
> Could the 4 verbosity levels just be tied to debug,info, warning, error 
> of python's logging module as default? 
>
> Thanks, 
> Christian 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/2da9ef10-178c-4173-bd82-061acf8733ca%40googlegroups.com.

Reply via email to