Fix double logging when running tests
This commit is contained in:
parent
e34a9d452a
commit
67d6b1e724
2 changed files with 6 additions and 4 deletions
|
@ -573,7 +573,7 @@ class Config(object):
|
||||||
logging.getLogger('').setLevel(logging.getLevelName(self.log_level))
|
logging.getLogger('').setLevel(logging.getLevelName(self.log_level))
|
||||||
logging.getLogger('').addHandler(file_logger)
|
logging.getLogger('').addHandler(file_logger)
|
||||||
|
|
||||||
def initLogging(self):
|
def initLogging(self, console_logging=True, file_logging=True):
|
||||||
# Create necessary files and dirs
|
# Create necessary files and dirs
|
||||||
if not os.path.isdir(self.log_dir):
|
if not os.path.isdir(self.log_dir):
|
||||||
os.mkdir(self.log_dir)
|
os.mkdir(self.log_dir)
|
||||||
|
@ -589,7 +589,9 @@ class Config(object):
|
||||||
logging.getLogger('').name = "-" # Remove root prefix
|
logging.getLogger('').name = "-" # Remove root prefix
|
||||||
logging.getLogger("geventwebsocket.handler").setLevel(logging.WARNING) # Don't log ws debug messages
|
logging.getLogger("geventwebsocket.handler").setLevel(logging.WARNING) # Don't log ws debug messages
|
||||||
|
|
||||||
self.initConsoleLogger()
|
if console_logging:
|
||||||
self.initFileLogger()
|
self.initConsoleLogger()
|
||||||
|
if file_logging:
|
||||||
|
self.initFileLogger()
|
||||||
|
|
||||||
config = Config(sys.argv)
|
config = Config(sys.argv)
|
||||||
|
|
|
@ -68,7 +68,7 @@ config.verbose = True # Use test data for unittests
|
||||||
config.tor = "disable" # Don't start Tor client
|
config.tor = "disable" # Don't start Tor client
|
||||||
config.trackers = []
|
config.trackers = []
|
||||||
config.data_dir = TEST_DATA_PATH # Use test data for unittests
|
config.data_dir = TEST_DATA_PATH # Use test data for unittests
|
||||||
config.initLogging()
|
config.initLogging(console_logging=False)
|
||||||
|
|
||||||
# Set custom formatter with realative time format (via: https://stackoverflow.com/questions/31521859/python-logging-module-time-since-last-log)
|
# Set custom formatter with realative time format (via: https://stackoverflow.com/questions/31521859/python-logging-module-time-since-last-log)
|
||||||
class TimeFilter(logging.Filter):
|
class TimeFilter(logging.Filter):
|
||||||
|
|
Loading…
Reference in a new issue