So far, I started my code with a "debug print message" and even "if condition: print debug message". But many people told me that this is not the best way to do this, and I really have to learn how to use the registration module. After a quick read, it seems that he is doing everything that I could want, and then some. It looks like a stand-alone training project, and I want to work on other projects now and just use minimal functionality to help me. If that matters, I'm on python 2.6 and will be in the foreseeable future due to library and legacy compatibility.
All I want to do at the moment is to rewrite my code with messages that I can enable and disable by sections, because I manage to debug specific regions. Like "hello_log_world", I tried this and it does not do what I expected
import logging
logging.error('first error')
logging.debug('first debug')
logging.basicConfig(level=logging.DEBUG)
logging.error('second error')
logging.debug('second debug')
You will notice that I am using a really basic configuration, using as much as possible by default so that everything is simple. But it seems that it is too simple or that I do not understand the programming model behind logging.
I expected sys.stderr to get
ERROR:root:first error
ERROR:root:second error
DEBUG:root:second debug
... but only two error messages appear. Installation Level = DEBUG does not display the second. If I uncomment the call to basicConfig at the beginning of the program, all four get the output.
Am I trying to run it at a too simple level?
, , , ?