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