mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 12:41:02 +02:00
Logging strategy updates
This commit is contained in:
parent
a520478af1
commit
e7eac8afa8
6 changed files with 33 additions and 13 deletions
|
|
@ -2,8 +2,12 @@
|
|||
import asyncio
|
||||
import uuid
|
||||
import msgpack
|
||||
import logging
|
||||
from . knowledge import KnowledgeRequestor
|
||||
|
||||
# Module logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class CoreExport:
|
||||
|
||||
def __init__(self, pulsar_client):
|
||||
|
|
@ -84,7 +88,7 @@ class CoreExport:
|
|||
|
||||
except Exception as e:
|
||||
|
||||
print("Exception:", e)
|
||||
logger.error(f"Core export exception: {e}", exc_info=True)
|
||||
|
||||
finally:
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@ import asyncio
|
|||
import json
|
||||
import uuid
|
||||
import msgpack
|
||||
import logging
|
||||
from . knowledge import KnowledgeRequestor
|
||||
|
||||
# Module logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class CoreImport:
|
||||
|
||||
def __init__(self, pulsar_client):
|
||||
|
|
@ -80,14 +84,14 @@ class CoreImport:
|
|||
await kr.process(msg)
|
||||
|
||||
except Exception as e:
|
||||
print("Exception:", e)
|
||||
logger.error(f"Core import exception: {e}", exc_info=True)
|
||||
await error(str(e))
|
||||
|
||||
finally:
|
||||
|
||||
await kr.stop()
|
||||
|
||||
print("All done.")
|
||||
logger.info("Core import completed")
|
||||
response = await ok()
|
||||
await response.write_eof()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
|
||||
import base64
|
||||
import logging
|
||||
|
||||
from ... schema import Document, Metadata
|
||||
from ... messaging import TranslatorRegistry
|
||||
|
||||
from . sender import ServiceSender
|
||||
|
||||
# Module logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class DocumentLoad(ServiceSender):
|
||||
def __init__(self, pulsar_client, queue):
|
||||
|
||||
|
|
@ -18,6 +22,6 @@ class DocumentLoad(ServiceSender):
|
|||
self.translator = TranslatorRegistry.get_request_translator("document")
|
||||
|
||||
def to_request(self, body):
|
||||
print("Document received")
|
||||
logger.info("Document received")
|
||||
return self.translator.to_pulsar(body)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
import asyncio
|
||||
from aiohttp import web
|
||||
import uuid
|
||||
import logging
|
||||
|
||||
# Module logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from . config import ConfigRequestor
|
||||
from . flow import FlowRequestor
|
||||
|
|
@ -92,12 +96,12 @@ class DispatcherManager:
|
|||
self.dispatchers = {}
|
||||
|
||||
async def start_flow(self, id, flow):
|
||||
print("Start flow", id)
|
||||
logger.info(f"Starting flow {id}")
|
||||
self.flows[id] = flow
|
||||
return
|
||||
|
||||
async def stop_flow(self, id, flow):
|
||||
print("Stop flow", id)
|
||||
logger.info(f"Stopping flow {id}")
|
||||
del self.flows[id]
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
|
||||
import base64
|
||||
import logging
|
||||
|
||||
from ... schema import TextDocument, Metadata
|
||||
from ... messaging import TranslatorRegistry
|
||||
|
||||
from . sender import ServiceSender
|
||||
|
||||
# Module logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class TextLoad(ServiceSender):
|
||||
def __init__(self, pulsar_client, queue):
|
||||
|
||||
|
|
@ -18,6 +22,6 @@ class TextLoad(ServiceSender):
|
|||
self.translator = TranslatorRegistry.get_request_translator("text-document")
|
||||
|
||||
def to_request(self, body):
|
||||
print("Text document received")
|
||||
logger.info("Text document received")
|
||||
return self.translator.to_pulsar(body)
|
||||
|
||||
|
|
|
|||
|
|
@ -74,24 +74,24 @@ class SocketEndpoint:
|
|||
self.listener(ws, dispatcher, running)
|
||||
)
|
||||
|
||||
print("Created taskgroup, waiting...")
|
||||
logger.debug("Created task group, waiting for completion...")
|
||||
|
||||
# Wait for threads to complete
|
||||
|
||||
print("Task group closed")
|
||||
logger.debug("Task group closed")
|
||||
|
||||
# Finally?
|
||||
await dispatcher.destroy()
|
||||
|
||||
except ExceptionGroup as e:
|
||||
|
||||
print("Exception group:", flush=True)
|
||||
logger.error("Exception group occurred:", exc_info=True)
|
||||
|
||||
for se in e.exceptions:
|
||||
print(" Type:", type(se), flush=True)
|
||||
print(f" Exception: {se}", flush=True)
|
||||
logger.error(f" Exception type: {type(se)}")
|
||||
logger.error(f" Exception: {se}")
|
||||
except Exception as e:
|
||||
print("Socket exception:", e, flush=True)
|
||||
logger.error(f"Socket exception: {e}", exc_info=True)
|
||||
|
||||
await ws.close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue