Logging strategy updates

This commit is contained in:
Cyber MacGeddon 2025-07-30 22:44:24 +01:00
parent e7eac8afa8
commit a4f531ba3e
11 changed files with 43 additions and 20 deletions

View file

@ -18,6 +18,9 @@ import logging
import os import os
import base64 import base64
import uuid import uuid
# Module logger
logger = logging.getLogger(__name__)
import json import json
import pulsar import pulsar
@ -48,7 +51,7 @@ class ConfigReceiver:
v = msg.value() v = msg.value()
print(f"Config version", v.version) logger.info(f"Config version: {v.version}")
if "flows" in v.config: if "flows" in v.config:
@ -68,29 +71,29 @@ class ConfigReceiver:
del self.flows[k] del self.flows[k]
except Exception as e: except Exception as e:
print(f"Exception: {e}", flush=True) logger.error(f"Config processing exception: {e}", exc_info=True)
async def start_flow(self, id, flow): async def start_flow(self, id, flow):
print("Start flow", id) logger.info(f"Starting flow: {id}")
for handler in self.flow_handlers: for handler in self.flow_handlers:
try: try:
await handler.start_flow(id, flow) await handler.start_flow(id, flow)
except Exception as e: except Exception as e:
print(f"Exception: {e}", flush=True) logger.error(f"Config processing exception: {e}", exc_info=True)
async def stop_flow(self, id, flow): async def stop_flow(self, id, flow):
print("Stop flow", id) logger.info(f"Stopping flow: {id}")
for handler in self.flow_handlers: for handler in self.flow_handlers:
try: try:
await handler.stop_flow(id, flow) await handler.stop_flow(id, flow)
except Exception as e: except Exception as e:
print(f"Exception: {e}", flush=True) logger.error(f"Config processing exception: {e}", exc_info=True)
async def config_loader(self): async def config_loader(self):
@ -111,9 +114,9 @@ class ConfigReceiver:
await self.config_cons.start() await self.config_cons.start()
print("Waiting...") logger.debug("Waiting for config updates...")
print("Config consumer done. :/") logger.info("Config consumer finished")
async def start(self): async def start(self):

View file

@ -2,12 +2,16 @@
import asyncio import asyncio
import queue import queue
import uuid import uuid
import logging
from ... schema import DocumentEmbeddings from ... schema import DocumentEmbeddings
from ... base import Subscriber from ... base import Subscriber
from . serialize import serialize_document_embeddings from . serialize import serialize_document_embeddings
# Module logger
logger = logging.getLogger(__name__)
class DocumentEmbeddingsExport: class DocumentEmbeddingsExport:
def __init__( def __init__(
@ -55,7 +59,7 @@ class DocumentEmbeddingsExport:
continue continue
except Exception as e: except Exception as e:
print(f"Exception: {str(e)}", flush=True) logger.error(f"Exception: {str(e)}", exc_info=True)
break break
await subs.unsubscribe_all(id) await subs.unsubscribe_all(id)

View file

@ -2,12 +2,16 @@
import asyncio import asyncio
import queue import queue
import uuid import uuid
import logging
from ... schema import EntityContexts from ... schema import EntityContexts
from ... base import Subscriber from ... base import Subscriber
from . serialize import serialize_entity_contexts from . serialize import serialize_entity_contexts
# Module logger
logger = logging.getLogger(__name__)
class EntityContextsExport: class EntityContextsExport:
def __init__( def __init__(
@ -55,7 +59,7 @@ class EntityContextsExport:
continue continue
except Exception as e: except Exception as e:
print(f"Exception: {str(e)}", flush=True) logger.error(f"Exception: {str(e)}", exc_info=True)
break break
await subs.unsubscribe_all(id) await subs.unsubscribe_all(id)

View file

@ -2,12 +2,16 @@
import asyncio import asyncio
import queue import queue
import uuid import uuid
import logging
from ... schema import GraphEmbeddings from ... schema import GraphEmbeddings
from ... base import Subscriber from ... base import Subscriber
from . serialize import serialize_graph_embeddings from . serialize import serialize_graph_embeddings
# Module logger
logger = logging.getLogger(__name__)
class GraphEmbeddingsExport: class GraphEmbeddingsExport:
def __init__( def __init__(
@ -55,7 +59,7 @@ class GraphEmbeddingsExport:
continue continue
except Exception as e: except Exception as e:
print(f"Exception: {str(e)}", flush=True) logger.error(f"Exception: {str(e)}", exc_info=True)
break break
await subs.unsubscribe_all(id) await subs.unsubscribe_all(id)

View file

@ -2,6 +2,10 @@
import asyncio import asyncio
import queue import queue
import uuid import uuid
import logging
# Module logger
logger = logging.getLogger(__name__)
MAX_OUTSTANDING_REQUESTS = 15 MAX_OUTSTANDING_REQUESTS = 15
WORKER_CLOSE_WAIT = 0.01 WORKER_CLOSE_WAIT = 0.01
@ -46,7 +50,7 @@ class Mux:
)) ))
except Exception as e: except Exception as e:
print("receive exception:", str(e), flush=True) logger.error(f"Receive exception: {str(e)}", exc_info=True)
await self.ws.send_json({"error": str(e)}) await self.ws.send_json({"error": str(e)})
async def maybe_tidy_workers(self, workers): async def maybe_tidy_workers(self, workers):
@ -138,7 +142,7 @@ class Mux:
except Exception as e: except Exception as e:
# This is an internal working error, may not be recoverable # This is an internal working error, may not be recoverable
print("run prepare exception:", e) logger.error(f"Run prepare exception: {e}", exc_info=True)
await self.ws.send_json({"id": id, "error": str(e)}) await self.ws.send_json({"id": id, "error": str(e)})
self.running.stop() self.running.stop()
@ -155,7 +159,7 @@ class Mux:
) )
except Exception as e: except Exception as e:
print("Exception2:", e) logger.error(f"Exception in mux: {e}", exc_info=True)
await self.ws.send_json({"error": str(e)}) await self.ws.send_json({"error": str(e)})
self.running.stop() self.running.stop()

View file

@ -68,7 +68,7 @@ class ServiceRequestor:
q.get(), timeout=self.timeout q.get(), timeout=self.timeout
) )
except Exception as e: except Exception as e:
print("Exception", e) logger.error(f"Request timeout exception: {e}", exc_info=True)
raise RuntimeError("Timeout") raise RuntimeError("Timeout")
if resp.error: if resp.error:

View file

@ -2,12 +2,16 @@
import asyncio import asyncio
import queue import queue
import uuid import uuid
import logging
from ... schema import Triples from ... schema import Triples
from ... base import Subscriber from ... base import Subscriber
from . serialize import serialize_triples from . serialize import serialize_triples
# Module logger
logger = logging.getLogger(__name__)
class TriplesExport: class TriplesExport:
def __init__( def __init__(
@ -55,7 +59,7 @@ class TriplesExport:
continue continue
except Exception as e: except Exception as e:
print(f"Exception: {str(e)}", flush=True) logger.error(f"Exception: {str(e)}", exc_info=True)
break break
await subs.unsubscribe_all(id) await subs.unsubscribe_all(id)

View file

@ -29,7 +29,7 @@ class ConstantEndpoint:
async def handle(self, request): async def handle(self, request):
print(request.path, "...") logger.debug(f"Processing request: {request.path}")
try: try:
ht = request.headers["Authorization"] ht = request.headers["Authorization"]

View file

@ -33,7 +33,7 @@ class MetricsEndpoint:
async def handle(self, request): async def handle(self, request):
print(request.path, "...") logger.debug(f"Processing metrics request: {request.path}")
try: try:
ht = request.headers["Authorization"] ht = request.headers["Authorization"]

View file

@ -36,7 +36,7 @@ class StreamEndpoint:
async def handle(self, request): async def handle(self, request):
print(request.path, "...") logger.debug(f"Processing request: {request.path}")
try: try:
ht = request.headers["Authorization"] ht = request.headers["Authorization"]

View file

@ -28,7 +28,7 @@ class VariableEndpoint:
async def handle(self, request): async def handle(self, request):
print(request.path, "...") logger.debug(f"Processing request: {request.path}")
try: try:
ht = request.headers["Authorization"] ht = request.headers["Authorization"]