feat(api): Integrate aggressive logging for all hook invocations

This commit is contained in:
2026-02-23 12:23:23 -05:00
parent 0d09007dc1
commit ef29902963
2 changed files with 26 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import json
import threading
from http.server import HTTPServer, BaseHTTPRequestHandler
import logging
import session_logger
class HookServerInstance(HTTPServer):
def __init__(self, server_address, RequestHandlerClass, app):
@@ -11,6 +12,7 @@ class HookServerInstance(HTTPServer):
class HookHandler(BaseHTTPRequestHandler):
def do_GET(self):
app = self.server.app
session_logger.log_api_hook("GET", self.path, "")
if self.path == '/status':
self.send_response(200)
self.send_header('Content-Type', 'application/json')
@@ -34,9 +36,11 @@ class HookHandler(BaseHTTPRequestHandler):
app = self.server.app
content_length = int(self.headers.get('Content-Length', 0))
body = self.rfile.read(content_length)
body_str = body.decode('utf-8') if body else ""
session_logger.log_api_hook("POST", self.path, body_str)
try:
data = json.loads(body.decode('utf-8')) if body else {}
data = json.loads(body_str) if body_str else {}
if self.path == '/api/project':
app.project = data.get('project', app.project)
self.send_response(200)