A community-maintained Python framework for creating mathematical animations.
Found a way for output changing
Syrus Darkfa179aef8ea6
diff --git a/example_scenes/rich.json b/example_scenes/rich.jsonnew file mode 100644index 000000000..40b5451a3--- /dev/null+++ b/example_scenes/rich.json@@ -0,0 +1 @@+{"info": "green", "danger": "bold red", "warning": "green", "logging.keyword":"red","logging.level.notset":"green","logging.level.info":"green","log.message":"green","log.path":"#000000"}\ No newline at end of filediff --git a/manim/extract_scene.py b/manim/extract_scene.pyindex 56c3bfe0a..c25e3aa09 100644--- a/manim/extract_scene.py+++ b/manim/extract_scene.py@@ -12,7 +12,7 @@ from .utils.sounds import play_error_soundfrom .utils.sounds import play_finish_soundfrom . import constantsfrom .logger import logger-+from .logger.console import consoledef open_file_if_needed(file_writer, **config):if config["quiet"]:@@ -77,10 +77,10 @@ def prompt_user_for_choice(scene_classes):num_to_class = {}for count, scene_class in zip(it.count(1), scene_classes):name = scene_class.__name__- print("%d: %s" % (count, name))+ console.print("%d: %s" % (count, name),style="warning")num_to_class[count] = scene_classtry:- user_input = input(constants.CHOOSE_NUMBER_MESSAGE)+ user_input = console.input("[log.message]"+constants.CHOOSE_NUMBER_MESSAGE+"[/log.message]")return [num_to_class[int(num_str)]for num_str in user_input.split(",")@@ -88,7 +88,7 @@ def prompt_user_for_choice(scene_classes):except KeyError:logger.error(constants.INVALID_NUMBER_MESSAGE)sys.exit(2)- user_input = input(constants.CHOOSE_NUMBER_MESSAGE)+ user_input = console.input(constants.CHOOSE_NUMBER_MESSAGE)return [num_to_class[int(num_str)]for num_str in user_input.split(",")diff --git a/manim/logger.py b/manim/logger.pydeleted file mode 100644index 416a06a80..000000000--- a/manim/logger.py+++ /dev/null@@ -1,12 +0,0 @@-import logging-from rich.logging import RichHandler---logging.basicConfig(- level="NOTSET",- format="%(message)s",- datefmt="[%X]",- handlers=[RichHandler()]-)--logger = logging.getLogger("rich")diff --git a/manim/logger/__init__.py b/manim/logger/__init__.pynew file mode 100644index 000000000..9c10e7e22--- /dev/null+++ b/manim/logger/__init__.py@@ -0,0 +1,16 @@+import logging+from rich.logging import RichHandler+from .console import console++RichHandler.KEYWORDS = ['Played', 'animations', 'scene', 'Reading', 'Writing', 'script', 'arguments', 'Invalid', 'Aborting', 'module', 'File', 'Rendering']+logging.basicConfig(+ level="NOTSET",+ format="%(message)s",+ datefmt="[%X]",+ handlers=[RichHandler(console=console)]+)++logger = logging.getLogger("rich")+++\ No newline at end of filediff --git a/manim/logger/__main__.py b/manim/logger/__main__.pynew file mode 100644index 000000000..32d4ff689--- /dev/null+++ b/manim/logger/__main__.py@@ -0,0 +1,20 @@+from .console import console+++if __name__=="__main__":+ default={"logging.keyword":"bold yellow",+ "logging.level.notset":"dim",+ "logging.level.debug":"green",+ "logging.level.info":"blue",+ "logging.level.warning":"red",+ "logging.level.error": "red bold",+ "logging.level.critical": "red bold reverse",+ "log.level":None,+ "log.time": "cyan dim",+ "log.message": None,+ "log.path": "dim",+ }+ console.print("[yellow bold]Manim Logger Configuration Editor[/yellow bold]",justify="center")+ for key in default:+ console.print('Enter the Style for %s'%key+':',style=key)+ default[key]=\ No newline at end of filediff --git a/manim/logger/console.py b/manim/logger/console.pynew file mode 100644index 000000000..c6df4ff69--- /dev/null+++ b/manim/logger/console.py@@ -0,0 +1,13 @@+import json+from rich.console import Console+from rich.theme import Theme++def parseTheme(fp):+ with open(fp,'r') as f:+ content=f.read()+ theme=json.loads(content)+ theme['listScenes']='yellow'+ customTheme=Theme(theme)+ return customTheme+customTheme = parseTheme("rich.json")+console = Console(theme=customTheme)\ No newline at end of filediff --git a/manim/logger/rich.json b/manim/logger/rich.jsonnew file mode 100644index 000000000..eb557657b--- /dev/null+++ b/manim/logger/rich.json@@ -0,0 +1 @@+{"info": "dim cyan", "warning": "yellow", "danger": "bold red", "listScenes": "yellow"}\ No newline at end of filediff --git a/manim/logger/theme.txt b/manim/logger/theme.txtnew file mode 100644index 000000000..3dbba6c97--- /dev/null+++ b/manim/logger/theme.txt@@ -0,0 +1,5 @@+[styles]+info = dim cyan+warning = magenta+danger = bold red+listScenes = yellow\ No newline at end of file