Skip to content

Commit

Permalink
added logger.py
Browse files Browse the repository at this point in the history
  • Loading branch information
arsalan-dev-engineer committed Aug 11, 2024
1 parent e02a27d commit 82b7518
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
85 changes: 85 additions & 0 deletions commands/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import time
from rich.console import Console
from rich.progress import Progress

console = Console()

def error(message: str):
"""Display critical errors that need immediate attention."""
console.print(message, style="bold red")

# ====================

def success(message: str):
"""Indicate successful operations or completed tasks."""
console.print(message, style="bold green")

# ====================

def warning(message: str):
"""Notify users of potential issues or cautions."""
console.print(message, style="bold yellow")

# ====================

def info(message: str):
"""Provide general information or updates about processes."""
console.print(message, style="bold blue")

# ====================

def debug(message: str):
"""Log debug information for troubleshooting purposes."""
console.print(message, style="bold white")

# ====================

def prompt_user(prompt_message: str) -> str:
"""Ask for user input or confirmations."""
return console.input(prompt_message)

# ====================

def show_progress(total: int):
"""Show the status of long-running operations."""
with Progress() as progress:
task = progress.add_task("[cyan]Processing...", total=total)
while not progress.finished:
time.sleep(0.1) # Simulate work being done
progress.update(task, advance=1)

# ====================

def completion(message: str):
"""Indicate the end of a process with a summary of results."""
console.print(message, style="bold green")

# ====================

def critical_alert(message: str):
"""Highlight urgent alerts or critical issues requiring immediate action."""
console.print(message, style="bold magenta")

# ====================

def network_status(message: str):
"""Indicate the status of network connections or related operations."""
console.print(message, style="bold bright_blue")

# ====================

def config_loaded(message: str):
"""Confirm that a configuration file has been successfully loaded."""
console.print(message, style="bold blue")

# ====================

def resource_status(message: str):
"""Report on the status of system resources (e.g., CPU, memory)."""
console.print(message, style="bold yellow")

# ====================

def execution_time(duration: float):
"""Display the time taken to complete a task."""
console.print(f"Execution time: {duration:.2f} seconds", style="bold white")
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ yt_dlp
fastapi
pydantic
typing
uvicorn
uvicorn
rich

0 comments on commit 82b7518

Please sign in to comment.