fix: replaced console logs with logger in adapters and agents#621
fix: replaced console logs with logger in adapters and agents#621otsybizov wants to merge 1 commit intomainnet-stagingfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR standardizes runtime logging across multiple agents and adapters by replacing console.* calls with the shared @chimera-monorepo/utils Logger, improving structured output and aligning error logging with jsonifyError(...).
Changes:
- Replaced
console.log/info/warn/errorwithLoggercalls across agents (watchtower, relayer, monitor, lighthouse, cartographer). - Introduced module-level loggers in several entrypoints/config/readers to ensure logs exist even before app context is initialized.
- Converted ad-hoc debug prints in chainservice providers/dispatch paths to structured debug/error logs.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/agents/watchtower/src/watcher.ts | Use Logger + jsonifyError for startup/setup failures; add fallback module logger. |
| packages/agents/watchtower/src/config.ts | Replace console config messages with Logger; add module logger. |
| packages/agents/relayer/src/make.ts | Replace console startup/setup errors with Logger; add fallback module logger. |
| packages/agents/relayer/src/config.ts | Replace console config messages with Logger; add module logger + jsonifyError on fetch failure. |
| packages/agents/relayer/src/bindings/server/index.ts | Replace server listen console error with structured Logger error. |
| packages/agents/relayer/src/bindings/relays/index.ts | Replace console debug prints in poll loop with Logger debug. |
| packages/agents/monitor/src/monitor.ts | Replace ASCII-art console print + startup console error with Logger. |
| packages/agents/monitor/src/index.ts | Replace lambda console logging with Logger; add module logger. |
| packages/agents/monitor/src/config.ts | Replace console config messages with Logger; add module logger. |
| packages/agents/monitor/src/checklist/gas.ts | Replace console error with context logger + jsonifyError. |
| packages/agents/lighthouse/src/index.ts | Replace lambda console logging with Logger; add module logger. |
| packages/agents/lighthouse/src/context.ts | Replace console prints/errors with Logger calls. |
| packages/agents/lighthouse/src/config.ts | Replace console config messages with Logger; add module logger + jsonifyError on failures. |
| packages/agents/cartographer/poller/src/pollers/index.ts | Replace ASCII-art console print with context logger. |
| packages/agents/cartographer/poller/src/index.ts | Replace lambda console logging with Logger; add module logger. |
| packages/agents/cartographer/core/src/config.ts | Replace console config messages with Logger; add module logger + jsonifyError on failures. |
| packages/adapters/subgraph/src/graph/reader.ts | Replace console errors with Logger; add module logger. |
| packages/adapters/subgraph/src/envio/reader.ts | Replace console errors with Logger; add module logger. |
| packages/adapters/chainservice/src/shared/rpc/tron/provider.ts | Replace extensive console debug/error output with structured Logger debug/error. |
| packages/adapters/chainservice/src/shared/rpc/eth/provider.ts | Replace console debug output with structured Logger debug; add module logger. |
| packages/adapters/chainservice/src/dispatch.ts | Replace console debug prints with dispatch logger debug. |
| packages/adapters/chainservice/src/aggregator.ts | Replace console debug prints with aggregator logger debug. |
| packages/adapters/cache/src/lib/caches/cache.ts | Replace Redis error console logging with Logger error + jsonifyError. |
Comments suppressed due to low confidence (2)
packages/agents/lighthouse/src/context.ts:204
- The catch block now logs the same failure twice via
logger.error(...)(one without ctx, then one with ctx), which will produce duplicate error entries. Consolidate to a singlelogger.errorcall (prefer the version that includesservice/chainscontext).
logger.error('Error creating lighthouse context. Sad! :(', requestContext, methodContext, jsonifyError(e as Error));
logger.error(
'Error creating lighthouse context. Sad! :(',
requestContext,
methodContext,
jsonifyError(e as Error),
{
service: config.service,
chains: [...Object.keys(config.chains)],
},
);
packages/adapters/subgraph/src/envio/reader.ts:44
- There is an
importdeclaration after executable code (const logger = ...). While valid syntax, it’s easy to miss and can confuse module initialization/hoisting behavior in different build targets. Move the../libimport block above theloggerinitialization so all imports are grouped at the top of the module.
const logger = new Logger({
level: 'info',
name: 'envio-reader',
formatters: {
level: (label) => ({ level: label.toUpperCase() }),
},
});
import {
getEnvioIntentByIdQuery,
getEnvioIntentsQuery,
QueryResponse,
SubgraphConfig,
SubgraphQueryMetaParams,
} from '../lib';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const pending = await cache.tasks.getPending(0, 100); | ||
| logger.debug('Retrieved pending tasks', _requestContext, methodContext, { pending: pending.length }); | ||
| console.log(`=== CONSOLE LOG TEST: pending tasks = ${pending.length} ===`); | ||
| logger.debug(`Pending tasks: ${pending.length}`, _requestContext, methodContext); |
There was a problem hiding this comment.
This adds a second debug log for the pending task count (Retrieved pending tasks already logs pending.length). Consider removing one of these to avoid redundant log volume in the hot polling loop.
| logger.debug(`Pending tasks: ${pending.length}`, _requestContext, methodContext); |
🤖 Linear
Closes CONG-XXX