Sunday, November 3, 2013

Re: Logging warnings inside settings.py

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iF4EAREIAAYFAlJ2nc4ACgkQtuvagsE+DE6lwwEA+JmlieWWHPKwBsiyHxX1/0Oc
AhpI+I7ZOyO9JYf2+v8A/2YKAyXRHIRq7tgQWJP54WK7bSTw69jR2u2NPKVrLeb0
=ilXp
-----END PGP SIGNATURE-----
On Fri, 1 Nov 2013 10:11:05 -0700 Jon Dufresne <jon.dufresne@gmail.com>
wrote:
> I am trying to log warnings inside settings.py. I want to log warnings
> when settings (from an outside source) are not provided, but the
> application can continue. Is this possible? It seems like this might
> not work as logging requires settings.py in order to be configured,
> but I want to log earlier than that.

I don't think you want to do that.

If I understand you correctly, you want a warning (or an error) if a
setting is not defined. The correct place to throw that warning is when
you need the setting, not when you define the setting.
Using settings.py for that would be wrong because the setting might be
set afterwards. Most settings.py I encounter or write have a ```try:
import local_settings``` at the bottom...

Have fun,

Arnold

No comments:

Post a Comment