Logging strategy updates

This commit is contained in:
Cyber MacGeddon 2025-07-30 22:38:39 +01:00
parent 0ad66dffb2
commit a520478af1
2 changed files with 10 additions and 6 deletions

View file

@ -517,7 +517,7 @@ class McpServer:
async for response in gen:
print(response)
logging.debug(f"Agent response: {response}")
if "thought" in response:
await ctx.session.send_log_message(

View file

@ -6,12 +6,16 @@ PDF document as text as separate output objects.
import tempfile
import base64
import logging
import pytesseract
from pdf2image import convert_from_bytes
from ... schema import Document, TextDocument, Metadata
from ... base import FlowProcessor, ConsumerSpec, ProducerSpec
# Module logger
logger = logging.getLogger(__name__)
default_ident = "pdf-decoder"
class Processor(FlowProcessor):
@ -41,15 +45,15 @@ class Processor(FlowProcessor):
)
)
print("PDF OCR inited")
logger.info("PDF OCR processor initialized")
async def on_message(self, msg, consumer, flow):
print("PDF message received", flush=True)
logger.info("PDF message received")
v = msg.value()
print(f"Decoding {v.metadata.id}...", flush=True)
logger.info(f"Decoding {v.metadata.id}...")
blob = base64.b64decode(v.data)
@ -60,7 +64,7 @@ class Processor(FlowProcessor):
try:
text = pytesseract.image_to_string(page, lang='eng')
except Exception as e:
print(f"Page did not OCR: {e}")
logger.warning(f"Page did not OCR: {e}")
continue
r = TextDocument(
@ -70,7 +74,7 @@ class Processor(FlowProcessor):
await flow("output").send(r)
print("Done.", flush=True)
logger.info("PDF decoding complete")
@staticmethod
def add_args(parser):