feat: migrate to new backend logging convention#4
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adopts the convention defined in
local-dev/logging.md. First of four backend migrations (provider/council/pay are pending).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.src/config/logger.tsnow exportscreateLogger();main.tsis the only construction site and threads{ log, bus }through to every service and free function.NetworkEventBusbecomes a DI'd class — takes{ log }in its constructor, no longer exported as a singleton. The strayconsole.warnin itspublish()catch is nowlog.error.handle<X>(deps)factory pattern.handleNetworkWs(deps)returns the request handler;buildNetworkWsRouter(deps)andbuildApiRouter(deps)wire it up.refreshWasmRegistry,fetchCouncilTopology,refreshTopology,coldStartScan,evaluateUnknownContract,drainPendingAdoptions,startSorobanWatcher,startScheduler) all take{ log, bus }deps and scope internally vialog.scope("funcName").describeErr()helper — the new Logger handles error stringification for both human and JSON sinks viainstanceof Error/safeJsonValue.console.warnper the convention's mapping rules.No OTEL changes (this repo has no OTEL today).
Logging coverage
handleNetworkWs)main.ts)Verified locally (pre-push)
deno fmt --check: cleandeno lint: clean (22 files)deno task test: 17 passed, 0 faileddeno task check: cleangrep -rn 'LOG\.(...)' src/: 0 hitsgrep -rn 'console\.(...)' src/: 0 hitsgrep -rn 'describeErr' src/: 0 hitsTest plan
LOG_LEVEL=infovialocal-dev/up.shto confirm output format matches the specLast commit (
chore: bump version to 0.1.4) is the patch-bump-alone commit per the open-pr-checklist.