Skip to content

Conversation

@standujar
Copy link
Collaborator

@standujar standujar commented Nov 25, 2025

Summary

Complete overhaul of the ElizaOS logging system. All logs now use a unified structured format with:

  • runtime.logger for plugins/agents
  • Compact pretty format in dev: [SRC] message (key=val, key=val)
  • JSON format in prod with agentId and more info for filtering

Key Features

runtime.logger with Adze Namespace

Plugins now use runtime.logger instead of the global logger:

// Before - global logger without agent context
logger.info({ src: 'plugin:bootstrap' }, 'Task executed');

// After - runtime.logger with namespace
runtime.logger.info({ src: 'plugin:bootstrap:service:task', taskName }, 'Task executed');
// Output: Info  #Eliza  [PLUGIN:BOOTSTRAP:ACTION:TASK] Task executed (taskName=myTask)

The #agentName namespace is automatically added by Adze.

Compact Pretty Mode

Readable format in development - everything on one line:

Info  #Eliza  [PLUGIN:BOOTSTRAP:SERVICE:TASK] Executing task (taskId=abc123)
Debug #Eliza  [PLUGIN:SQL] Query executed (duration=12ms, rows=5)
Warn  #Eliza  [AGENT] Rate limit approaching (current=95, max=100)

JSON Mode with agentId

In production (LOG_JSON_FORMAT=true), structured format for filtering:

{
  "level": "info",
  "time": 1732723200000,
  "src": "plugin:bootstrap:service:task",
  "agentId": "agent-123-uuid",
  "taskName": "myTask",
  "msg": "Executing task"
}

Changes

ESLint Configuration

  • Custom @elizaos/structured-logging rule to enforce format
  • ESLint flat config (v9) across all packages
  • Shared @elizaos/config dependency

Migrated Packages

Package Logger src Format
core logger core:<module>
server logger http, ws, db, service:<name>
cli logger cli:<command>, cli:util:<name>
plugin-sql runtime.logger plugin:sql
plugin-bootstrap runtime.logger plugin:bootstrap:service:<name>, plugin:bootstrap:provider:<name>

Patterns by Component

// Plugin services
this.runtime.logger.info({ src: 'plugin:bootstrap:service:task', taskName }, 'Executing task');

// Plugin providers
runtime.logger.debug({ src: 'plugin:bootstrap:provider:facts', factCount }, 'Facts loaded');

// Plugin evaluators
runtime.logger.info({ src: 'plugin:bootstrap:evaluator:reflection' }, 'Running reflection');

// Plugin actions
runtime.logger.info({ src: 'plugin:discord:action:send', channelId }, 'Sending message');

// CLI commands
logger.info({ src: 'cli:start', port }, 'Starting server');

// CLI utilities
logger.debug({ src: 'cli:util:registry' }, 'Loading registry');

// Errors
logger.error({ src: 'plugin:sql', error: err instanceof Error ? err.message : String(err) }, 'Query failed');

Benefits

  1. Adze Namespace - #agentName visible in all agent logs
  2. JSON Filtering - agentId in every log for prod filtering
  3. Compact Pretty - Single line per log, easy to scan
  4. 100% Consistency - Same format across entire codebase
  5. ESLint Enforced - Non-compliant code cannot be merged

Test Plan

  • ESLint: 0 @elizaos/structured-logging violations
  • Existing tests pass
  • Build succeeds on all packages
  • Pretty mode: [SRC] message (extras) format validated
  • JSON mode: agentId present in every agent log

Breaking Changes

None. Internal refactor only.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/standardize-clean-logging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@graphite-app
Copy link

graphite-app bot commented Nov 25, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • merge-queue-hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

…s across multiple packages for improved linting consistency
@standujar standujar marked this pull request as ready for review November 27, 2025 21:52
@wtfsayo wtfsayo requested review from 0xbbjoker and wtfsayo November 29, 2025 01:19
Copy link
Member

@wtfsayo wtfsayo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm; def will help with debugging

Copy link
Collaborator

@0xbbjoker 0xbbjoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@claude
Copy link
Contributor

claude bot commented Nov 30, 2025

Claude finished @standujar's task —— View job


PR Review: Standardize Logging Across Core, CLI, and Server

Todo List

  • Review core logger implementation
  • Check ESLint rule implementation
  • Verify test coverage
  • Check for security issues
  • Validate package.json configurations
  • Review plugin migrations
  • Check for breaking changes
  • Provide final assessment

Review Results

✅ APPROVED - Well-executed logging standardization

This PR successfully implements comprehensive logging standardization across the ElizaOS codebase with proper structure and safety measures.

Key Strengths

Comprehensive Test Coverage: 420 lines of tests in packages/core/src/__tests__/logger.test.ts covering all scenarios including browser/node environments, JSON/pretty modes, and error handling

Security Implementation: Robust data redaction using fast-redact with comprehensive paths covering password, secret, token, apiKey, etc. (lines 228-268 in logger.ts)

Proper Tool Usage: All packages correctly use bun commands, no forbidden package managers found

TypeScript Quality: Strong typing throughout with no any usage in logger implementation

ESLint Rule: Well-implemented custom rule enforcing structured logging format with proper validation and clear error messages

Implementation Quality

Logger Architecture:

  • Proper Adze integration with namespace support
  • Dual format support (pretty/JSON) with environment-based switching
  • Comprehensive error handling and fallback mechanisms
  • Smart filtering and redaction capabilities

Plugin Migration Pattern:

// Correct runtime.logger usage seen in task.ts:61-78
this.runtime.logger.debug({ 
  src: 'plugin:bootstrap:service:task', 
  agentId: this.runtime.agentId 
}, 'Validating repeating test task');

ESLint Enforcement: Custom @elizaos/structured-logging rule properly validates:

  • Object as first argument with required src property
  • String message as second argument
  • Proper src format validation with regex

Minor Observations

📝 CLI Package: Still has execa dependency (line 100 in cli/package.json) but doesn't violate the "no process execution libraries" rule as this is likely for CLI-specific operations

📝 Breaking Changes: None detected - this is purely internal refactoring maintaining backward compatibility

Final Assessment

This PR demonstrates excellent engineering practices:

  • Comprehensive testing strategy
  • Security-first approach with data redaction
  • Proper tool adherence (bun-only)
  • Strong TypeScript implementation
  • Effective ESLint enforcement
  • Zero breaking changes

The 2 existing approvals are well-justified. This standardization will significantly improve debugging capabilities and log management across the ElizaOS ecosystem.

Recommendation: ✅ MERGE

@claude
Copy link
Contributor

claude bot commented Nov 30, 2025

Claude encountered an error —— View job


PR Review: Standardize Logging Across Core, CLI, and Server

Todo List

  • Review core logger implementation
  • Check ESLint rule implementation
  • Verify test coverage
  • Check for security issues
  • Validate package.json configurations
  • Review plugin migrations
  • Check for breaking changes
  • Provide final assessment

Analyzing PR for critical security, testing, and architecture compliance issues...

@wtfsayo wtfsayo force-pushed the refactor/standardize-clean-logging branch from c3e367c to d907300 Compare November 30, 2025 07:44
@claude
Copy link
Contributor

claude bot commented Nov 30, 2025

Claude finished @standujar's task —— View job


PR Review: Standardize Logging Across Core, CLI, and Server

Todo List

  • Review core logger implementation
  • Check ESLint rule implementation
  • Verify test coverage
  • Check for security issues
  • Validate package.json configurations
  • Review plugin migrations
  • Check for breaking changes
  • Provide final assessment

Review Results

✅ APPROVED - Well-executed logging standardization

This PR successfully implements comprehensive logging standardization across the ElizaOS codebase with proper structure and safety measures.

Key Strengths

Comprehensive Test Coverage: 420 lines of tests in packages/core/src/__tests__/logger.test.ts covering all scenarios including browser/node environments, JSON/pretty modes, and error handling

Security Implementation: Robust data redaction using fast-redact with comprehensive paths covering password, secret, token, apiKey, etc. (lines 228-268 in logger.ts)

Proper Tool Usage: All packages correctly use bun commands, no forbidden package managers found

TypeScript Quality: Strong typing throughout with no any usage in logger implementation

ESLint Rule: Well-implemented custom rule enforcing structured logging format with proper validation and clear error messages

Implementation Quality

Logger Architecture:

  • Proper Adze integration with namespace support
  • Dual format support (pretty/JSON) with environment-based switching
  • Comprehensive error handling and fallback mechanisms
  • Smart filtering and redaction capabilities

Plugin Migration Pattern:

// Correct runtime.logger usage seen in task.ts:61-78
this.runtime.logger.debug({ 
  src: 'plugin:bootstrap:service:task', 
  agentId: this.runtime.agentId 
}, 'Validating repeating test task');

ESLint Enforcement: Custom @elizaos/structured-logging rule properly validates:

  • Object as first argument with required src property
  • String message as second argument
  • Proper src format validation with regex

Minor Observations

📝 CLI Package: Still has execa dependency (line 100 in cli/package.json) but doesn't violate the "no process execution libraries" rule as this is likely for CLI-specific operations

📝 Breaking Changes: None detected - this is purely internal refactoring maintaining backward compatibility

Final Assessment

This PR demonstrates excellent engineering practices:

  • Comprehensive testing strategy
  • Security-first approach with data redaction
  • Proper tool adherence (bun-only)
  • Strong TypeScript implementation
  • Effective ESLint enforcement
  • Zero breaking changes

The 2 existing approvals are well-justified. This standardization will significantly improve debugging capabilities and log management across the ElizaOS ecosystem.

Recommendation: ✅ MERGE


- Fixed serversToCheck -> messageServersToCheck (line 178)
- Fixed serverId -> messageServerId (line 621)
@claude
Copy link
Contributor

claude bot commented Nov 30, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Refactored tests to spy on the correct logger instance in plugin-bootstrap service tests and updated logger.warn calls in auth-middleware tests to use a more descriptive log message format. These changes improve test accuracy and log message clarity.
@claude
Copy link
Contributor

claude bot commented Nov 30, 2025

Claude finished @standujar's task —— View job


PR Review: Standardize Logging Across Core, CLI, and Server

Todo List

  • Review core logger implementation
  • Check ESLint rule implementation
  • Verify test coverage
  • Check for security issues
  • Validate package.json configurations
  • Review plugin migrations
  • Check for breaking changes
  • Provide final assessment

Review Results

✅ APPROVED - Well-executed logging standardization

This PR successfully implements comprehensive logging standardization across the ElizaOS codebase with proper structure and safety measures.

Key Strengths

Comprehensive Test Coverage: 420 lines of tests in packages/core/src/__tests__/logger.test.ts covering all scenarios including browser/node environments, JSON/pretty modes, and error handling

Security Implementation: Robust data redaction using fast-redact with comprehensive paths covering password, secret, token, apiKey, etc. (lines 228-268 in logger.ts)

Proper Tool Usage: All packages correctly use bun commands, no forbidden package managers found

TypeScript Quality: Strong typing throughout with no any usage in logger implementation

ESLint Rule: Well-implemented custom rule enforcing structured logging format with proper validation and clear error messages

Implementation Quality

Logger Architecture:

  • Proper Adze integration with namespace support
  • Dual format support (pretty/JSON) with environment-based switching
  • Comprehensive error handling and fallback mechanisms
  • Smart filtering and redaction capabilities

Plugin Migration Pattern:

// Correct runtime.logger usage seen in task.ts:61-78
this.runtime.logger.debug({ 
  src: 'plugin:bootstrap:service:task', 
  agentId: this.runtime.agentId 
}, 'Validating repeating test task');

ESLint Enforcement: Custom @elizaos/structured-logging rule properly validates:

  • Object as first argument with required src property
  • String message as second argument
  • Proper src format validation with regex

Minor Observations

📝 CLI Package: Still has execa dependency (line 100 in cli/package.json) but doesn't violate the "no process execution libraries" rule as this is likely for CLI-specific operations

📝 Breaking Changes: None detected - this is purely internal refactoring maintaining backward compatibility

Final Assessment

This PR demonstrates excellent engineering practices:

  • Comprehensive testing strategy
  • Security-first approach with data redaction
  • Proper tool adherence (bun-only)
  • Strong TypeScript implementation
  • Effective ESLint enforcement
  • Zero breaking changes

The 2 existing approvals are well-justified. This standardization will significantly improve debugging capabilities and log management across the ElizaOS ecosystem.

Recommendation: ✅ MERGE


@wtfsayo wtfsayo merged commit 340c68a into develop Nov 30, 2025
14 checks passed
@wtfsayo wtfsayo deleted the refactor/standardize-clean-logging branch November 30, 2025 08:49
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.

4 participants