Print a debug message when the logging config file doesn't exist
This commit is contained in:
parent
ada23997a9
commit
b737d17172
@ -36,18 +36,22 @@ LOGGER = logging.getLogger()
|
|||||||
|
|
||||||
def start():
|
def start():
|
||||||
filename = os.path.expanduser(config.get("logging", "config"))
|
filename = os.path.expanduser(config.get("logging", "config"))
|
||||||
|
debug = config.getboolean("logging", "debug")
|
||||||
|
|
||||||
"""Start the logging according to the configuration."""
|
"""Start the logging according to the configuration."""
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
# Configuration taken from file
|
# Configuration taken from file
|
||||||
logging.config.fileConfig(filename)
|
logging.config.fileConfig(filename)
|
||||||
|
if debug:
|
||||||
|
LOGGER.setLevel(logging.DEBUG)
|
||||||
|
for handler in LOGGER.handlers:
|
||||||
|
handler.setLevel(logging.DEBUG)
|
||||||
else:
|
else:
|
||||||
# Default configuration, standard output
|
# Default configuration, standard output
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
handler.setFormatter(logging.Formatter("%(message)s"))
|
handler.setFormatter(logging.Formatter("%(message)s"))
|
||||||
LOGGER.addHandler(handler)
|
LOGGER.addHandler(handler)
|
||||||
|
if debug:
|
||||||
if config.getboolean("logging", "debug"):
|
|
||||||
LOGGER.setLevel(logging.DEBUG)
|
LOGGER.setLevel(logging.DEBUG)
|
||||||
for handler in LOGGER.handlers:
|
LOGGER.debug("Logging configuration file '%s' not found, using stdout."
|
||||||
handler.setLevel(logging.DEBUG)
|
% filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user