Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add more debugging messages #180

Merged
merged 7 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manim_slides/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def callback(ctx: Context, param: Parameter, value: bool) -> None:
"-v",
"--verbosity",
type=click.Choice(
["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
["PERF", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
case_sensitive=False,
),
help="Verbosity of CLI output",
Expand Down
5 changes: 5 additions & 0 deletions manim_slides/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import logging

from rich.console import Console
from rich.logging import RichHandler
from rich.theme import Theme

__all__ = ["logger", "make_logger"]

Expand Down Expand Up @@ -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


Expand Down
15 changes: 15 additions & 0 deletions manim_slides/present.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,21 @@ def run(self) -> None:

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()
Expand Down