From 38f40e07509b72a2520472fd5128d53d64d35251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kami=C5=84ski?= Date: Fri, 25 Oct 2024 13:31:50 +0000 Subject: [PATCH] client log file rotation --- scripts/data/client.py | 11 ++++++++++- scripts/data/integration_tests.sh | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/data/client.py b/scripts/data/client.py index e6e63e88..b61db136 100755 --- a/scripts/data/client.py +++ b/scripts/data/client.py @@ -14,6 +14,8 @@ import random from generate_data import generate_data from format_args import format_args +import logging +from logging.handlers import TimedRotatingFileHandler logger = logging.getLogger(__name__) @@ -290,7 +292,14 @@ def main(start, blocks, step, mode, strategy): MAX_WEIGHT_LIMIT = args.maxweight - file_handler = logging.FileHandler("client.errors.log") + # file_handler = logging.FileHandler("client.log") + file_handler = TimedRotatingFileHandler( + filename="client.log", + when="midnight", + interval=1, + backupCount=14, + encoding="utf8" + ) file_handler.setLevel(logging.INFO) file_handler.setFormatter( logging.Formatter("%(asctime)s - %(name)-10.10s - %(levelname)s - %(message)s") diff --git a/scripts/data/integration_tests.sh b/scripts/data/integration_tests.sh index cf32e288..a86f7967 100755 --- a/scripts/data/integration_tests.sh +++ b/scripts/data/integration_tests.sh @@ -73,7 +73,7 @@ for test_file in "${test_files[@]}"; do echo " ignored" num_ignored=$((num_ignored + 1)) else - arguments_file=".arguments-$(basename "$test_file")" + arguments_file="$(dirname "$test_file")/.arguments-$(basename "$test_file")" python ../../scripts/data/format_args.py --input_file ${test_file} $([[ $execute_scripts -eq 1 ]] && echo "--execute_script") > $arguments_file output=$(scarb cairo-run --no-build --function main --arguments-file $arguments_file) gas_spent=$(echo $output | grep -o 'gas_spent=[0-9]*' | sed 's/gas_spent=//')