56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
from typing import Any, Dict
|
|
|
|
def format_connection_status(status: Dict[str, Any]) -> str:
|
|
"""
|
|
Format connection status for logging
|
|
|
|
Args:
|
|
status: Connection status dictionary
|
|
|
|
Returns:
|
|
Formatted status string
|
|
"""
|
|
connection_status = status.get('connection_status', 'unknown')
|
|
dht_nodes = status.get('dht_nodes', 0)
|
|
return f"Status: {connection_status}, DHT Nodes: {dht_nodes}"
|
|
|
|
def format_debug_metrics(metrics: Dict[str, Any]) -> str:
|
|
"""
|
|
Format debug metrics for logging
|
|
|
|
Args:
|
|
metrics: Dictionary of debug metrics
|
|
|
|
Returns:
|
|
Formatted debug metrics string
|
|
"""
|
|
parts = []
|
|
|
|
if 'transition_info' in metrics:
|
|
parts.append(metrics['transition_info'])
|
|
if 'failure_info' in metrics:
|
|
parts.append(metrics['failure_info'])
|
|
if 'last_failure_info' in metrics:
|
|
parts.append(metrics['last_failure_info'])
|
|
if 'remediation_info' in metrics:
|
|
parts.append(metrics['remediation_info'])
|
|
if 'stability_info' in metrics:
|
|
parts.append(metrics['stability_info'])
|
|
|
|
return " - ".join(parts)
|
|
|
|
def format_torrent_list(torrents: list) -> str:
|
|
"""
|
|
Format torrent list for logging
|
|
|
|
Args:
|
|
torrents: List of torrent dictionaries
|
|
|
|
Returns:
|
|
Formatted torrent list string
|
|
"""
|
|
if not torrents:
|
|
return "No torrents"
|
|
|
|
hashes = [torrent.get('hash', 'unknown') for torrent in torrents]
|
|
return f"{len(hashes)} torrents: {'|'.join(hashes[:3])}{'...' if len(hashes) > 3 else ''}" |