Skip to content

fix: replaced console logs with logger in adapters and agents#621

Closed
otsybizov wants to merge 1 commit intomainnet-stagingfrom
fix/replace-console-logging
Closed

fix: replaced console logs with logger in adapters and agents#621
otsybizov wants to merge 1 commit intomainnet-stagingfrom
fix/replace-console-logging

Conversation

@otsybizov
Copy link
Contributor

🤖 Linear

Closes CONG-XXX

Copilot AI review requested due to automatic review settings March 25, 2026 20:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/error with Logger calls 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 single logger.error call (prefer the version that includes service/chains context).
    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 import declaration 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 ../lib import block above the logger initialization 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);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
logger.debug(`Pending tasks: ${pending.length}`, _requestContext, methodContext);

Copilot uses AI. Check for mistakes.
@otsybizov otsybizov closed this Mar 25, 2026
@otsybizov otsybizov deleted the fix/replace-console-logging branch March 25, 2026 20:17
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.

2 participants