[BACKEND] Reset debug log on every subscription
This commit is contained in:
parent
5d40d02eb3
commit
0fdecc762f
2 changed files with 19 additions and 5 deletions
|
|
@ -40,7 +40,7 @@ def _download_subscriptions_from_yaml_files(
|
|||
subscriptions: List[Subscription] = []
|
||||
output: List[Tuple[Subscription, FileHandlerTransactionLog]] = []
|
||||
|
||||
# Load all of the subscriptions first to perform all validation before downloading
|
||||
# Load all the subscriptions first to perform all validation before downloading
|
||||
for path in subscription_paths:
|
||||
subscriptions += Subscription.from_file_path(config=config, subscription_path=path)
|
||||
|
||||
|
|
@ -55,6 +55,7 @@ def _download_subscriptions_from_yaml_files(
|
|||
|
||||
output.append((subscription, transaction_log))
|
||||
gc.collect() # Garbage collect after each subscription download
|
||||
Logger.cleanup() # Cleanup logger after each successful subscription download
|
||||
|
||||
return output
|
||||
|
||||
|
|
|
|||
|
|
@ -94,13 +94,26 @@ class TestLogger:
|
|||
|
||||
assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"]
|
||||
|
||||
# Ensure the file cleans up too
|
||||
for handler in logger.handlers:
|
||||
handler.close()
|
||||
|
||||
Logger.cleanup(delete_debug_file=True)
|
||||
assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name)
|
||||
|
||||
|
||||
def test_logger_can_be_cleaned_during_execution(self):
|
||||
Logger._LOGGER_LEVEL = LoggerLevels.INFO
|
||||
logger = Logger.get(name="name_test")
|
||||
|
||||
for _ in range(2):
|
||||
logger.info("info test")
|
||||
logger.debug("debug test")
|
||||
|
||||
with open(Logger._DEBUG_LOGGER_FILE.name, "r", encoding="utf-8") as log_file:
|
||||
lines = log_file.readlines()
|
||||
|
||||
assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"]
|
||||
|
||||
Logger.cleanup(delete_debug_file=True)
|
||||
assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"log_level, expected_stdout",
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in a new issue