Fix double logging when running tests

This commit is contained in:
shortcutme 2019-07-10 03:12:56 +02:00
parent e34a9d452a
commit 67d6b1e724
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 6 additions and 4 deletions

View file

@ -573,7 +573,7 @@ class Config(object):
logging.getLogger('').setLevel(logging.getLevelName(self.log_level))
logging.getLogger('').addHandler(file_logger)
def initLogging(self):
def initLogging(self, console_logging=True, file_logging=True):
# Create necessary files and dirs
if not os.path.isdir(self.log_dir):
os.mkdir(self.log_dir)
@ -589,7 +589,9 @@ class Config(object):
logging.getLogger('').name = "-" # Remove root prefix
logging.getLogger("geventwebsocket.handler").setLevel(logging.WARNING) # Don't log ws debug messages
self.initConsoleLogger()
self.initFileLogger()
if console_logging:
self.initConsoleLogger()
if file_logging:
self.initFileLogger()
config = Config(sys.argv)

View file

@ -68,7 +68,7 @@ config.verbose = True # Use test data for unittests
config.tor = "disable" # Don't start Tor client
config.trackers = []
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)
class TimeFilter(logging.Filter):