Closed smlbiobot closed 4 years ago
It's something I've thought about.
The short answer, out of the box is "no". But it would be very easy to implement yourself:
Create a new file where you always import debug from:
import os
__all__ = ('debug',)
if os.getenv('DEBUG', '').upper() == 'TRUE':
from devtools import debug
else:
def debug(*args, **kwargs):
pass
Then set the DEBUG
env variable when you want debug()
to work, or you could reverse the check to look for some environment variable in production, or you could not install devtools in production and do
try:
from devtools import debug
except ImportError:
def debug(*args, **kwargs):
pass
Does that make sense?
just for completeness, personally I like deleting all debug commands before releasing - one of the advantages of the auto import system (or not including devtools to your requirements file) is that if you do miss one when pushing, CI fails.
I read the docs but I can’t see any options to turn off the module once development has been completed. I find all the features very useful, but now my code has a lot of these debug codes that I would prefer to keep but not output when I’m ready to put them in production. Is there a way? Thanks!