Skip to content

feat: standardizes logging across the Notify-Chain listener service for easier debugging and monitoring. All production code now uses the centralized Winston logger with consistent structure, log levels, timestamps, and error formatting.#109

Merged
Abd-Standard merged 2 commits into
Core-Foundry:mainfrom
miss-yusrah:feat/script
Jun 19, 2026

Conversation

@miss-yusrah

Copy link
Copy Markdown
Contributor

Summary

Standardizes logging across the Notify-Chain listener service for easier debugging and monitoring. All production code now uses the centralized Winston logger with consistent structure, log levels, timestamps, and error formatting.

closes #9

Changes

Logger utility (listener/src/utils/logger.ts)

  • Added formatError() helper that normalizes errors into structured objects (message, name, stack, cause)
  • All error metadata fields are automatically formatted before logging
  • Exposed debug, info, warn, and error levels with consistent metadata handling
  • Timestamps remain ISO 8601 via Winston; dev output is colorized, production output is newline-delimited JSON

Service logging consistency

  • Discord notifications: Removed duplicate "Discord notification sent successfully" log; single "Discord notification delivered" entry with full context
  • Notification scheduler: Added requestId per poll batch, durationMs on batch/notification operations, and debug-level empty poll cycle logs
  • Scheduled notification repository & API: Thread optional requestId through create/schedule/cancel operations
  • Events API: Passes requestId into scheduling calls for end-to-end traceability
  • Event registry: Emits warn when evicting oldest events at capacity

Scripts & configuration

  • Replaced all console.log / console.error in example scripts with structured logger calls
  • Added LOG_LEVEL=info to listener/.env.example
  • Synced listener/package-lock.json with existing sqlite3 and uuid dependencies

Documentation & tests

  • Updated listener/LOGGING.md with scheduler lifecycle events, registry warnings, and error formatting guidance
  • Added listener/src/utils/logger.test.ts for formatError()
  • Updated event-registry.test.ts to verify capacity eviction warnings

CI fix

  • Applied cargo fmt to contract/contracts/hello-world/src/autoshare_logic.rs (pre-existing formatting drift that would fail the Rust fmt check)

Acceptance criteria

  • Logging is consistent throughout the listener project (Winston + structured metadata everywhere)
  • Log levels are used appropriately (debug, info, warn, error)
  • Timestamps included on every log entry (Winston timestamp() format)
  • Errors contain useful debugging information (message, name, stack, optional cause)

Test plan

  • cd listener && npm run build — TypeScript compiles cleanly
  • cd listener && npx jest src/utils/logger.test.ts src/store/event-registry.test.ts src/services/discord-notification.test.ts — new and affected tests pass
  • cd dashboard && npm run lint && npm run build && npm test — CI frontend job passes
  • cd contract && cargo fmt --all -- --check && cargo test --workspace --all-features — CI Rust job passes
  • Manual: run listener with LOG_LEVEL=debug and confirm scheduler poll cycles appear
  • Manual: trigger a Discord webhook failure and confirm structured error output includes stack trace

Configuration

# listener/.env
LOG_LEVEL=info        # debug | info | warn | error
# NODE_ENV=production # uncomment for JSON log output

…or easier debugging and monitoring. All production code now uses the centralized Winston logger with consistent structure, log levels, timestamps, and error formatting.
@Abd-Standard Abd-Standard merged commit 5f2a3c8 into Core-Foundry:main Jun 19, 2026
1 of 2 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 19, 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.

Refactor Logging System

2 participants