A community-maintained Python framework for creating mathematical animations.
Fix #453: log files naming, when scene is not specified, is fixed
charlie4fun9b61e3d0b72a
diff --git a/manim/config/config.py b/manim/config/config.pyindex a44222386..325311dc7 100644--- a/manim/config/config.py+++ b/manim/config/config.py@@ -157,9 +157,18 @@ camera_config = configset_rich_logger(config_parser["logger"], file_writer_config["verbosity"])if file_writer_config["log_to_file"]:# IMPORTANT note about file name : The log file name will be the scene_name get from the args (contained in file_writer_config). So it can differ from the real name of the scene.+ scene_name_suffix = "".join(file_writer_config["scene_names"])+ scene_file_name = os.path.basename(args.file).split(".")[+ 0+ ] # takes filename and removes extension+ log_file_name = (+ f"{scene_file_name}_{scene_name_suffix}.log"+ if scene_name_suffix+ else f"{scene_file_name}.log"+ )log_file_path = os.path.join(file_writer_config["log_dir"],- "".join(file_writer_config["scene_names"]) + ".log",+ log_file_name,)set_file_logger(log_file_path)- logger.info("Log file wil be saved in %(logpath)s", {"logpath": log_file_path})+ logger.info("Log file will be saved in %(logpath)s", {"logpath": log_file_path})diff --git a/tests/control_data/logs_data/BasicSceneLoggingTest.txt b/tests/control_data/logs_data/BasicSceneLoggingTest.txtindex 8b947a2c4..e7595ef9b 100644--- a/tests/control_data/logs_data/BasicSceneLoggingTest.txt+++ b/tests/control_data/logs_data/BasicSceneLoggingTest.txt@@ -1,4 +1,4 @@-{"levelname": "INFO", "module": "config", "message": "Log file wil be saved in <>"}+{"levelname": "INFO", "module": "config", "message": "Log file will be saved in <>"}{"levelname": "DEBUG", "module": "hashing", "message": "Hashing ..."}{"levelname": "DEBUG", "module": "hashing", "message": "Hashing done in <> s."}{"levelname": "INFO", "module": "scene_file_writer", "message": "Animation 0 : Partial movie file written in <>"}diff --git a/tests/test_logging/basic_scenes_square_to_circle.py b/tests/test_logging/basic_scenes_square_to_circle.pynew file mode 100644index 000000000..c1b835cbc--- /dev/null+++ b/tests/test_logging/basic_scenes_square_to_circle.py@@ -0,0 +1,8 @@+from manim import *++# This module is used in the CLI tests in tests_CLi.py.+++class SquareToCircle(Scene):+ def construct(self):+ self.play(Transform(Square(), Circle()))diff --git a/tests/test_logging/basic_scenes.py b/tests/test_logging/basic_scenes_wirte_stuff.pysimilarity index 82%rename from tests/test_logging/basic_scenes.pyrename to tests/test_logging/basic_scenes_wirte_stuff.pyindex 3f190f36e..e08719b66 100644--- a/tests/test_logging/basic_scenes.py+++ b/tests/test_logging/basic_scenes_wirte_stuff.py@@ -3,11 +3,6 @@ from manim import *# This module is used in the CLI tests in tests_CLi.py.-class SquareToCircle(Scene):- def construct(self):- self.play(Transform(Square(), Circle()))--class WriteStuff(Scene):def construct(self):example_text = Tex("This is a some text", tex_to_color_map={"text": YELLOW})diff --git a/tests/test_logging/test_logging.py b/tests/test_logging/test_logging.pyindex a180c7315..76bcb433c 100644--- a/tests/test_logging/test_logging.py+++ b/tests/test_logging/test_logging.py@@ -9,10 +9,13 @@ from ..utils.logging_tester import *@logs_comparison(- "BasicSceneLoggingTest.txt", os.path.join("logs", "SquareToCircle.log")+ "BasicSceneLoggingTest.txt",+ os.path.join("logs", "basic_scenes_square_to_circle_SquareToCircle.log"),)def test_logging_to_file(tmp_path, python_version):- path_basic_scene = os.path.join("tests", "test_logging", "basic_scenes.py")+ path_basic_scene = os.path.join(+ "tests", "test_logging", "basic_scenes_square_to_circle.py"+ )command = [python_version,"-m",@@ -28,3 +31,27 @@ def test_logging_to_file(tmp_path, python_version):]_, err, exitcode = capture(command)assert exitcode == 0, err+++@logs_comparison(+ "BasicSceneLoggingTest.txt",+ os.path.join("logs", "basic_scenes_square_to_circle.log"),+)+def test_logging_when_scene_is_not_specified(tmp_path, python_version):+ path_basic_scene = os.path.join(+ "tests", "test_logging", "basic_scenes_square_to_circle.py"+ )+ command = [+ python_version,+ "-m",+ "manim",+ path_basic_scene,+ "-l",+ "--log_to_file",+ "-v",+ "DEBUG",+ "--media_dir",+ str(tmp_path),+ ]+ _, err, exitcode = capture(command)+ assert exitcode == 0, err