Skip to content

feat(scripts): migrate keeper/indexer/health-check/alert-failed-charges to shared logger - #1003

Merged
orunganiekan merged 4 commits into
SiLioLabs:masterfrom
divinemike019:feat/issue-878-structured-logger-migration
Aug 31, 2026
Merged

feat(scripts): migrate keeper/indexer/health-check/alert-failed-charges to shared logger#1003
orunganiekan merged 4 commits into
SiLioLabs:masterfrom
divinemike019:feat/issue-878-structured-logger-migration

Conversation

@divinemike019

Copy link
Copy Markdown

Summary

Migrates the four core operational scripts to the shared logger.ts structured logger, replacing all ad-hoc console.log/console.info patterns with leveled JSON-capable logging that respects LOG_LEVEL.

Changes

scripts/keeper.ts

  • Replace local log(dryRun, msg) helper with rootLogger.child({ script: 'keeper', contract: CONTRACT_ID, rpc: RPC_URL })
  • All call sites updated to logger.debug/info/warn/error with structured context fields
  • LOG_LEVEL env var now respected via the shared logger
  • console.error kept only in validateEnv() fatal bootstrap (pre-logger-init)
  • console.log in showHelp() is intentional CLI help-text output to stdout (not a log line)

scripts/indexer.ts

  • Replace local log(level, msg) + hand-rolled LOG_LEVEL check with rootLogger.child({ script: 'indexer', contract: CONTRACT_ID, rpc: RPC_URL })
  • All call sites use logger.debug/info/error with structured context fields
  • console.error kept only in pre-init CONTRACT_ID guard and main().catch fatal path

scripts/health-check.ts

  • Remove stale duplicate imports and local timestamp() / log() helpers
  • Use rootLogger.child({ script: 'health-check', contract: CONTRACT_ID, rpc: RPC_URL })
  • All call sites use logger.info/error with structured context

scripts/alert-failed-charges.ts

  • Fix stale console.error syntax error in sendWebhook; correct misuse of logger.error for info-level events
  • Use logger.child({ script: 'alert-failed-charges', db: dbPath }) in main() (no contract/rpc — not applicable for a DB-only script)
  • console.error kept only in pre-init WEBHOOK_URL guard

scripts/README.md

  • Add JSON log line example to the Logs and metrics section under Keeper
  • Add LOG_LEVEL and LOG_FORMAT rows to the keeper environment variable table and the full environment matrix

Acceptance Criteria

  • All four scripts use the shared logger for non-fatal logs
  • LOG_LEVEL is respected via parseLevel(process.env.LOG_LEVEL) in createLogger
  • Required fields (script, contract, rpc where applicable) appear on every log line
  • README shows one example JSON log line from keeper

Example log line (keeper, LOG_FORMAT=json)

{"timestamp":"2026-08-30T17:45:00.123Z","level":"INFO","message":"Keeper started in LIVE mode","script":"keeper","contract":"CAAAA...","rpc":"https://soroban-testnet.stellar.org","mode":"live"}

Closes #878

adimd and others added 4 commits August 30, 2026 18:36
…es to shared logger

- keeper.ts: replace local log(dryRun, msg) with logger.child({script,
  contract, rpc}); structured context on every line; LOG_LEVEL now
  respected; console.error kept only in validateEnv() fatal bootstrap
- indexer.ts: replace local log(level, msg) + hand-rolled LOG_LEVEL
  with logger.child({script, contract, rpc}); all call sites use
  logger.debug/info/error with structured context fields
- health-check.ts: remove stale duplicate imports (Account, Server,
  Contract); remove timestamp() helper and local log() wrapper; use
  logger.child({script, contract, rpc}) with logger.info/error
- alert-failed-charges.ts: fix stale console.error syntax error in
  sendWebhook; correct logger.error misuse for info-level events;
  logger.child({script, db}) in main()
- scripts/README.md: update Logs and metrics section with JSON log line
  example; add LOG_LEVEL/LOG_FORMAT rows to keeper variables table

Closes SiLioLabs#878
…ts, add LOG_FORMAT row

Update the 'Environment variable reference' table in scripts/README.md:
- LOG_LEVEL 'Used by' column now lists keeper, indexer, health-check, and
  alert-failed-charges (was keeper, indexer only)
- Add missing LOG_FORMAT row with the same four scripts in 'Used by'

Closes SiLioLabs#878
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@divinemike019 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

@orunganiekan
orunganiekan merged commit 47ce2a4 into SiLioLabs:master Aug 31, 2026
0 of 3 checks passed
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.

Issue 083: Migrate keeper, indexer, health-check, and alert-failed-charges to shared structured logger

2 participants