Skip to content

🪚 refactor: Optimize CONSOLE_JSON Debug Logs with Truncation#4709

Merged
danny-avila merged 1 commit into
mainfrom
refactor/console-json-truncation
Nov 13, 2024
Merged

🪚 refactor: Optimize CONSOLE_JSON Debug Logs with Truncation#4709
danny-avila merged 1 commit into
mainfrom
refactor/console-json-truncation

Conversation

@danny-avila

Copy link
Copy Markdown
Owner

Summary

I implemented a new logging format to optimize CONSOLE_JSON debug logs by truncating long strings and condensing arrays. This was already done for non-JSON logging to console. This enhancement improves log readability and reduces log file sizes while maintaining essential debugging information.

  • Created jsonTruncateFormat in parsers.js to handle log message truncation
  • Implemented recursive object traversal to process nested objects and arrays
  • Set string truncation limit to 255 characters for optimal log size
  • Applied the new format to Console transports in winston.js configuration
  • Maintained JSON formatting for structured logging while reducing verbosity
  • Updated debug console configuration to use the new truncation format

Change Type

  • New feature (non-breaking change which adds functionality)

Testing

I tested the changes by:

  1. Generating debug logs with various payload sizes
  2. Verifying truncation of long strings
  3. Confirming nested object handling
  4. Checking array condensing functionality
  5. Validating JSON structure remains intact

Test Configuration:

  • Environment: Development
  • Debug Mode: Enabled
  • Console JSON: Enabled

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
  • Local unit tests pass with my changes

@danny-avila danny-avila merged commit 493e64e into main Nov 13, 2024
@danny-avila danny-avila deleted the refactor/console-json-truncation branch November 13, 2024 02:53
BertKiv pushed a commit to BertKiv/LibreChat that referenced this pull request Dec 10, 2024
MichielMAnalytics pushed a commit to MichielMAnalytics/ProAI that referenced this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant