Skip to content

feat(logging): implement structured logging with levels and JSON output (#101) - #229

Merged
LaGodxy merged 1 commit into
MettaChain:mainfrom
Nuel-ship-it:feature/101-structured-logging
Apr 29, 2026
Merged

LaGodxy merged 1 commit into
MettaChain:mainfrom
Nuel-ship-it:feature/101-structured-logging

Conversation

@Nuel-ship-it

Copy link
Copy Markdown
Contributor

Summary

Closes #101

Standardizes logging across the entire app on a single interface with proper log levels, structured JSON output in production, and sensitive data redaction.

Changes

src/utils/logger.ts — single source of truth

  • Log levels: DEBUG, INFO, WARN, ERROR, SILENT
  • JSON production output: jsonOutput: true in production emits newline-delimited JSON for log aggregators (Datadog, CloudWatch, etc.)
  • Sensitive data redaction: strips private keys, tokens, passwords, mnemonics, PII from all log data before output
  • Correlation IDs: auto-generated per session, forkable for async operations

src/utils/structuredLogger.ts — domain helpers, no duplication

  • Re-exports everything from logger.ts (single import point for callers)
  • Adds domain-specific helpers: performance(), network(), web3(), transaction(), component()

39 files updated

Replaced raw console.log/warn/error/debug/info calls with logger.* equivalents across hooks, lib services, security utilities, components, and API routes.

Acceptance Criteria

  • Single logging interface throughout the app (logger from @/utils/logger)
  • Log levels: DEBUG, INFO, WARN, ERROR
  • Structured JSON logs in production (jsonOutput: true when NODE_ENV=production)
  • Sensitive data redaction (private keys, tokens, passwords, PII)

Testing

TypeScript type check passes with zero new errors. Pre-existing errors in FloatingComparisonBar, PropertyCard, WalletModal, comparisonStore are unrelated to this PR (confirmed by stash test).

…ut (MettaChain#101)

- Refactor logger.ts as single source of truth with DEBUG/INFO/WARN/ERROR levels
- Add jsonOutput flag: emits JSON lines in production for log aggregators
- Add sensitive data redaction (private keys, tokens, passwords, PII)
- Add correlation ID tracking across requests
- Update structuredLogger.ts to re-export from logger (no duplication)
  - Adds domain helpers: performance, network, web3, component
- Replace raw console.* calls with logger.* in 39 files across:
  - hooks, lib services, security utils, components, API routes

Closes MettaChain#101
@drips-wave

drips-wave Bot commented Apr 28, 2026

Copy link
Copy Markdown

@Nuel-ship-it Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@LaGodxy
LaGodxy merged commit 851d3a5 into MettaChain:main Apr 29, 2026
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.

Improvement: Implement proper logging levels and structured logging

2 participants