mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 04:31:02 +02:00
Fix formatting error
This commit is contained in:
parent
ca9be84530
commit
47eae4a2b3
1 changed files with 8 additions and 2 deletions
|
|
@ -24,7 +24,13 @@ def format_message(queue_name, msg):
|
||||||
|
|
||||||
# Try to parse as JSON and pretty-print
|
# Try to parse as JSON and pretty-print
|
||||||
try:
|
try:
|
||||||
value = msg.value()
|
# Handle both Message objects and raw bytes
|
||||||
|
if hasattr(msg, 'value'):
|
||||||
|
# Message object with .value() method
|
||||||
|
value = msg.value()
|
||||||
|
else:
|
||||||
|
# Raw bytes from schema-less subscription
|
||||||
|
value = msg
|
||||||
|
|
||||||
# If it's bytes, decode it
|
# If it's bytes, decode it
|
||||||
if isinstance(value, bytes):
|
if isinstance(value, bytes):
|
||||||
|
|
@ -51,7 +57,7 @@ def format_message(queue_name, msg):
|
||||||
body = str(value)
|
body = str(value)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
body = f"<Error formatting message: {e}>\n{msg.value()}"
|
body = f"<Error formatting message: {e}>\n{str(msg)}"
|
||||||
|
|
||||||
# Format the output
|
# Format the output
|
||||||
header = f"\n{'='*80}\n[{timestamp}] Queue: {queue_name}\n{'='*80}\n"
|
header = f"\n{'='*80}\n[{timestamp}] Queue: {queue_name}\n{'='*80}\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue