MCPcopy
hub / github.com/1rgs/claude-code-proxy / log_request_beautifully

Function log_request_beautifully

server.py:1664–1700  ·  view source on GitHub ↗

Log requests in a beautiful, twitter-friendly format showing Claude to OpenAI mapping.

(
    method, path, claude_model, openai_model, num_messages, num_tools, status_code
)

Source from the content-addressed store, hash-verified

1662
1663
1664def log_request_beautifully(
1665 method, path, claude_model, openai_model, num_messages, num_tools, status_code
1666):
1667 """Log requests in a beautiful, twitter-friendly format showing Claude to OpenAI mapping."""
1668 # Format the Claude model name nicely
1669 claude_display = f"{Colors.CYAN}{claude_model}{Colors.RESET}"
1670
1671 # Extract endpoint name
1672 endpoint = path
1673 if "?" in endpoint:
1674 endpoint = endpoint.split("?")[0]
1675
1676 # Extract just the OpenAI model name without provider prefix
1677 openai_display = openai_model
1678 if "/" in openai_display:
1679 openai_display = openai_display.split("/")[-1]
1680 openai_display = f"{Colors.GREEN}{openai_display}{Colors.RESET}"
1681
1682 # Format tools and messages
1683 tools_str = f"{Colors.MAGENTA}{num_tools} tools{Colors.RESET}"
1684 messages_str = f"{Colors.BLUE}{num_messages} messages{Colors.RESET}"
1685
1686 # Format status code
1687 status_str = (
1688 f"{Colors.GREEN}✓ {status_code} OK{Colors.RESET}"
1689 if status_code == 200
1690 else f"{Colors.RED}✗ {status_code}{Colors.RESET}"
1691 )
1692
1693 # Put it all together in a clear, beautiful format
1694 log_line = f"{Colors.BOLD}{method} {endpoint}{Colors.RESET} {status_str}"
1695 model_line = f"{claude_display} → {openai_display} {tools_str} {messages_str}"
1696
1697 # Print to console
1698 print(log_line)
1699 print(model_line)
1700 sys.stdout.flush()
1701
1702
1703if __name__ == "__main__":

Callers 2

create_messageFunction · 0.85
count_tokensFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected