I have a basic configuration set in my project
From, for example __init__.py:
import logging
logging.basicConfig(level=logging.INFO)
And I would like to change the global level at runtime after reading user parameters. Is that possible without moving the previous lines after that?
A full example will be something like the following:
logger = logging.getLogger(__name__)
def run():
parser = OptionParser()
parser.add_option("--debug", dest="debug",
action="store_true",
help="flag to indicate if debug should be enabled",
default=False)
(options, args) = parser.parse_args()
if options.debug:
# change the logging configuration
pass
#logging.basicConfig(level=logging.DEBUG)
# call the application code
optparsemodule has been deprecated, please switch to usingargparse