feat: improve debug message handling with better truncation and formatting
This commit is contained in:
@@ -538,9 +538,7 @@ async def extract_entities(
|
|||||||
verbose_debug(
|
verbose_debug(
|
||||||
f"New entities:{all_entities_data}, relationships:{all_relationships_data}"
|
f"New entities:{all_entities_data}, relationships:{all_relationships_data}"
|
||||||
)
|
)
|
||||||
verbose_debug(
|
verbose_debug(f"New relationships:{all_relationships_data}")
|
||||||
f"New relationships:{all_relationships_data}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if entity_vdb is not None:
|
if entity_vdb is not None:
|
||||||
data_for_vdb = {
|
data_for_vdb = {
|
||||||
|
@@ -25,10 +25,26 @@ VERBOSE_DEBUG = os.getenv("VERBOSE", "false").lower() == "true"
|
|||||||
def verbose_debug(msg: str, *args, **kwargs):
|
def verbose_debug(msg: str, *args, **kwargs):
|
||||||
"""Function for outputting detailed debug information.
|
"""Function for outputting detailed debug information.
|
||||||
When VERBOSE_DEBUG=True, outputs the complete message.
|
When VERBOSE_DEBUG=True, outputs the complete message.
|
||||||
When VERBOSE_DEBUG=False, outputs only the first 30 characters.
|
When VERBOSE_DEBUG=False, outputs only the first 50 characters.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
msg: The message format string
|
||||||
|
*args: Arguments to be formatted into the message
|
||||||
|
**kwargs: Keyword arguments passed to logger.debug()
|
||||||
"""
|
"""
|
||||||
if VERBOSE_DEBUG:
|
if VERBOSE_DEBUG:
|
||||||
logger.debug(msg, *args, **kwargs)
|
logger.debug(msg, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
# Format the message with args first
|
||||||
|
if args:
|
||||||
|
formatted_msg = msg % args
|
||||||
|
else:
|
||||||
|
formatted_msg = msg
|
||||||
|
# Then truncate the formatted message
|
||||||
|
truncated_msg = (
|
||||||
|
formatted_msg[:50] + "..." if len(formatted_msg) > 50 else formatted_msg
|
||||||
|
)
|
||||||
|
logger.debug(truncated_msg, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def set_verbose_debug(enabled: bool):
|
def set_verbose_debug(enabled: bool):
|
||||||
|
Reference in New Issue
Block a user