Returned logger setting to debug though slightly deduplicated

This commit is contained in:
Dmitri Bogomolov 2018-06-27 11:24:09 +03:00
parent da3e72186d
commit 795b855c65
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
1 changed files with 10 additions and 14 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
""" """
Logging and debuging facility Logging and debuging facility
============================= =============================
@ -11,7 +10,7 @@ Levels:
Confirmation that things are working as expected. Confirmation that things are working as expected.
WARNING WARNING
An indication that something unexpected happened, or indicative of some problem in the An indication that something unexpected happened, or indicative of some problem in the
near future (e.g. disk space low). The software is still working as expected. near future (e.g. 'disk space low'). The software is still working as expected.
ERROR ERROR
Due to a more serious problem, the software has not been able to perform some function. Due to a more serious problem, the software has not been able to perform some function.
CRITICAL CRITICAL
@ -113,10 +112,10 @@ def configureLogging():
return True return True
if __name__ == "__main__": # TODO (xj9): Get from a config file.
# logger = logging.getLogger('console_only')
# TODO (xj9): Get from a config file. def initLogging():
#logger = logging.getLogger('console_only')
if configureLogging(): if configureLogging():
if '-c' in sys.argv: if '-c' in sys.argv:
logger = logging.getLogger('file_only') logger = logging.getLogger('file_only')
@ -124,8 +123,8 @@ if __name__ == "__main__":
logger = logging.getLogger('both') logger = logging.getLogger('both')
else: else:
logger = logging.getLogger('default') logger = logging.getLogger('default')
else: return logger
logger = logging.getLogger('default')
def restartLoggingInUpdatedAppdataLocation(): def restartLoggingInUpdatedAppdataLocation():
global logger global logger
@ -133,11 +132,8 @@ def restartLoggingInUpdatedAppdataLocation():
logger.removeHandler(i) logger.removeHandler(i)
i.flush() i.flush()
i.close() i.close()
if configureLogging(): logger = initLogging()
if '-c' in sys.argv:
logger = logging.getLogger('file_only')
else:
logger = logging.getLogger('both')
else:
logger = logging.getLogger('default')
# !
logger = initLogging()