feat(cli): add more debugging messages (#180)

* feat(cli): add more debugging messages

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* chore(lib): fix msg to be more correct

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* chore(version): setup dummy version


chore(version): fix

* chore(ci): udpate version in __version__ too

* chore(version): revert changes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Jérome Eertmans
2023-05-04 10:54:24 +02:00
committed by GitHub
parent 4da0e2cc2d
commit 8ab33ef71f
3 changed files with 21 additions and 1 deletions

View File

@ -54,7 +54,7 @@ def verbosity_option(function: F) -> F:
"-v",
"--verbosity",
type=click.Choice(
["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
["PERF", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
case_sensitive=False,
),
help="Verbosity of CLI output",

View File

@ -5,7 +5,9 @@ https://github.com/ManimCommunity/manim/blob/d5b65b844b8ce8ff5151a2f56f9dc98cebb
import logging
from rich.console import Console
from rich.logging import RichHandler
from rich.theme import Theme
__all__ = ["logger", "make_logger"]
@ -33,9 +35,12 @@ def make_logger() -> logging.Logger:
RichHandler.KEYWORDS = HIGHLIGHTED_KEYWORDS
rich_handler = RichHandler(
show_time=True,
console=Console(theme=Theme({"logging.level.perf": "magenta"})),
)
logging.addLevelName(5, "PERF")
logger = logging.getLogger("manim-slides")
logger.addHandler(rich_handler)
return logger

View File

@ -448,6 +448,21 @@ class Display(QThread): # type: ignore
lag = now() - last_time
sleep_time = 1 / self.current_presentation.fps
logger.log(
5,
f"Took {lag:.3f} seconds to process the current frame, that must play at a rate of one every {sleep_time:.3f} seconds.",
)
if sleep_time - lag < 0:
logger.warn(
"The FPS rate could not be matched. "
"This is normal when manually transitioning between slides.\n"
"If you feel that the FPS are too low, "
"consider checking this issue:\n"
"https://github.com/jeertmans/manim-slides/issues/179."
)
sleep_time = max(sleep_time - lag, 0)
time.sleep(sleep_time)
last_time = now()