28 lines
760 B
Python
28 lines
760 B
Python
|
|
import aiofiles
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
from rich.console import Console
|
||
|
|
from rich.panel import Panel
|
||
|
|
|
||
|
|
console = Console()
|
||
|
|
|
||
|
|
|
||
|
|
def print_description(description: str, frame_number: int) -> None:
|
||
|
|
timestamp = datetime.now().strftime("%H:%M:%S")
|
||
|
|
console.print(
|
||
|
|
Panel(
|
||
|
|
description,
|
||
|
|
title=f"[bold cyan]Frame #{frame_number}[/bold cyan] [{timestamp}]",
|
||
|
|
border_style="blue",
|
||
|
|
)
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
async def log_description(
|
||
|
|
log_file: str, description: str, frame_number: int
|
||
|
|
) -> None:
|
||
|
|
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||
|
|
line = f"[{timestamp}] Frame #{frame_number}: {description}\n"
|
||
|
|
async with aiofiles.open(log_file, "a", encoding="utf-8") as f:
|
||
|
|
await f.write(line)
|