mirror of
https://github.com/HelloZeroNet/ZeroNet.git
synced 2023-12-14 04:33:03 +01:00
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('').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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue