forked from BoraDurkun/Colendi-API-Python-Wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathws_logger.py
More file actions
27 lines (23 loc) · 795 Bytes
/
ws_logger.py
File metadata and controls
27 lines (23 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
# ws_logger.py
import sys, json
from datetime import datetime
from rich.console import Console
from rich.panel import Panel
console = Console()
def main():
console.print("🟢 Logger başladı. Mesaj bekleniyor...\n")
for raw in sys.stdin:
raw = raw.strip()
if not raw:
continue
try:
data = json.loads(raw)
ts = datetime.now().strftime("%H:%M:%S")
title = f"[bold green]📩 {ts}[/bold green]"
pretty = json.dumps(data, indent=2, ensure_ascii=False)
console.print(Panel.fit(pretty, title=title, border_style="green"))
except json.JSONDecodeError:
console.print(f"[red]⚠ JSON parse hatası[/red]: {raw}")
if __name__ == "__main__":
main()