Skip to content

feat: migrate to new backend logging convention#4

Merged
AquiGorka merged 4 commits into
mainfrom
backend-logging-convention
May 31, 2026
Merged

feat: migrate to new backend logging convention#4
AquiGorka merged 4 commits into
mainfrom
backend-logging-convention

Conversation

@AquiGorka
Copy link
Copy Markdown
Contributor

Summary

Adopts the convention defined in local-dev/logging.md. First of four backend migrations (provider/council/pay are pending).

  • New Logger at src/utils/logger/index.ts — TS port of AquiGorka/go-logger. Five methods (info, event, debug, error, scope), four levels (Debug, Info, Event, Disabled), nested scopes, dual stdout-human / file-JSON output.
  • No module-level singleton. src/config/logger.ts now exports createLogger(); main.ts is the only construction site and threads { log, bus } through to every service and free function.
  • NetworkEventBus becomes a DI'd class — takes { log } in its constructor, no longer exported as a singleton. The stray console.warn in its publish() catch is now log.error.
  • HTTP routes use the handle<X>(deps) factory pattern. handleNetworkWs(deps) returns the request handler; buildNetworkWsRouter(deps) and buildApiRouter(deps) wire it up.
  • Sync free functions (refreshWasmRegistry, fetchCouncilTopology, refreshTopology, coldStartScan, evaluateUnknownContract, drainPendingAdoptions, startSorobanWatcher, startScheduler) all take { log, bus } deps and scope internally via log.scope("funcName").
  • Removed the local describeErr() helper — the new Logger handles error stringification for both human and JSON sinks via instanceof Error / safeJsonValue.
  • Migrated all 42 LOG calls + the one stray console.warn per the convention's mapping rules.

No OTEL changes (this repo has no OTEL today).

Logging coverage

Subsystem Levels emitted
HTTP routes (handleNetworkWs) info, event, debug, error
Background services (soroban-watcher, scheduler) info, event, debug, error
External API calls (council-platform, GitHub releases, Stellar RPC) info, event, debug, error
Error paths error
Bootstrap (main.ts) info, event, debug, error

Verified locally (pre-push)

  • deno fmt --check: clean
  • deno lint: clean (22 files)
  • deno task test: 17 passed, 0 failed
  • deno task check: clean
  • grep -rn 'LOG\.(...)' src/: 0 hits
  • grep -rn 'console\.(...)' src/: 0 hits
  • grep -rn 'describeErr' src/: 0 hits

Test plan

  • CI green on this branch
  • PM merges PR #100 (logging convention doc) first, then this
  • Smoke test locally with LOG_LEVEL=info via local-dev/up.sh to confirm output format matches the spec

Last commit (chore: bump version to 0.1.4) is the patch-bump-alone commit per the open-pr-checklist.

AquiGorka added 4 commits May 27, 2026 12:30
Replaces the previous custom Logger (six-level variadic LOG singleton)
with the convention defined in local-dev/logging.md:

- Five-method Logger interface: info, event, debug, error, scope.
  Source ported from github.com/AquiGorka/go-logger, lives at
  src/utils/logger/index.ts. Dual stdout-human / file-JSON output.
- src/config/logger.ts now exports createLogger() (no module-level
  singleton). main.ts is the only place the root logger is created.
- NetworkEventBus becomes a DI'd class (takes { log } in constructor);
  main.ts constructs it and passes deps into the soroban watcher,
  scheduler, and HTTP routes.
- All sync free functions (refreshWasmRegistry, fetchCouncilTopology,
  refreshTopology, coldStartScan, evaluateUnknownContract, etc.) take
  { log, bus } deps. Internal scoping via log.scope("funcName").
- WebSocket route exposes handleNetworkWs(deps) factory and
  buildNetworkWsRouter(deps). v1.routes.ts now exports
  buildApiRouter(deps).
- Removed local describeErr() helper — the new Logger stringifies
  errors internally for both human and JSON sinks.
- Migrated all 42 LOG call sites + the one stray console.warn in
  events/bus.ts.

No OTEL changes (this repo had no OTEL to begin with).
- NetworkEventBus: subscribe, publish entry breadcrumbs + debug for
  listener count and event kind.
- soroban-watcher: publishMappedEvent + processRawEventBatch take log;
  callers updated.

deno check src clean.
@AquiGorka AquiGorka merged commit 8550196 into main May 31, 2026
5 checks passed
@AquiGorka AquiGorka deleted the backend-logging-convention branch May 31, 2026 16:54
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