Skip to content

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

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

fix: replaced console logs with logger in adapters and agents#619
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 16:35
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 replaces console.* logging with the shared Logger across multiple agents and adapters to standardize/structure logs and reduce raw console output.

Changes:

  • Replaced console.log/info/warn/error calls with Logger calls across agents/adapters.
  • Added module-level Logger instances in several entrypoints/config modules (including Lambda handlers).
  • Converted ad-hoc debug console prints in ChainService providers/dispatch paths into structured debug logs.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
packages/agents/watchtower/src/watcher.ts Use Logger for startup/context error reporting (adds fallback logger).
packages/agents/watchtower/src/config.ts Replace console logging during config parsing/fetch with Logger.
packages/agents/relayer/src/make.ts Use Logger for relayer startup/context errors (adds fallback logger).
packages/agents/relayer/src/config.ts Replace console logging during config load/fetch with Logger.
packages/agents/relayer/src/bindings/server/index.ts Replace server startup console.error with structured Logger.error.
packages/agents/relayer/src/bindings/relays/index.ts Replace temporary console debug prints in poll loop with logger.debug.
packages/agents/monitor/src/monitor.ts Replace banner/startup console logging with context.logger.
packages/agents/monitor/src/index.ts Replace Lambda console logs with structured Logger invocation log.
packages/agents/monitor/src/config.ts Replace config-load console output with Logger calls.
packages/agents/monitor/src/checklist/gas.ts Replace relayer fetch error console.error with logger.error.
packages/agents/lighthouse/src/index.ts Replace Lambda console logs with structured Logger invocation log.
packages/agents/lighthouse/src/context.ts Replace banner/startup console logging with logger.info/error.
packages/agents/lighthouse/src/config.ts Replace config-load console output with Logger calls.
packages/agents/cartographer/poller/src/pollers/index.ts Replace poller banner console logging with context.logger.
packages/agents/cartographer/poller/src/index.ts Replace Lambda console logs with structured Logger invocation log.
packages/agents/cartographer/core/src/config.ts Replace config-load console output with Logger calls.
packages/adapters/subgraph/src/graph/reader.ts Replace subgraph query console.error with structured logger.error.
packages/adapters/subgraph/src/envio/reader.ts Replace Envio query console.error with structured logger.error (adds module logger).
packages/adapters/chainservice/src/shared/rpc/tron/provider.ts Replace extensive Tron debug console logs with structured logger.debug/error.
packages/adapters/chainservice/src/shared/rpc/eth/provider.ts Replace provider debug console logs with structured debug logger.
packages/adapters/chainservice/src/dispatch.ts Replace dispatch console debug prints with this.logger.debug.
packages/adapters/chainservice/src/aggregator.ts Replace aggregator console debug prints with this.logger.debug.
packages/adapters/cache/src/lib/caches/cache.ts Replace Redis connection console.error with structured logger.error.
Comments suppressed due to low confidence (1)

packages/adapters/subgraph/src/envio/reader.ts:41

  • This file now has an import statement after executable code (const logger = ...). In TypeScript/ESM, imports must come before other statements, so this will fail to compile. Move the logger initialization below all imports (or merge the later import { ... } from '../lib' up with the other imports).
const logger = new Logger({
  level: 'info',
  name: 'envio-reader',
  formatters: {
    level: (label) => ({ level: label.toUpperCase() }),
  },
});
import {
  getEnvioIntentByIdQuery,
  getEnvioIntentsQuery,
  QueryResponse,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 169 to 171
} catch (e) {
console.error('Failed to fetch everclear config:', e);
logger.error('Failed to fetch everclear config', undefined, undefined, undefined, { error: e });
}
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 call won’t include the thrown error because Logger.error overwrites ctx.error with its explicit 4th argument (currently undefined). Pass jsonifyError(e as Error) as the 4th parameter instead of { error: e } in the context.

Copilot uses AI. Check for mistakes.
Comment on lines 347 to 349
} catch (error) {
console.error('TRON DEBUG: Smart contract transaction failed:', error);
logger.error('Smart contract transaction failed', undefined, undefined, undefined, { error });
if (error instanceof Error) {
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.

Logger.error(..., undefined, { error }) drops the error because Logger.error overwrites ctx.error with its explicit 4th argument (here undefined). Pass jsonifyError(error as Error) (or convert to ErrorJson) as the 4th parameter so the failure reason is logged.

Copilot uses AI. Check for mistakes.
everclearConfig = await getEverclearConfig(everclearConfigUrl);
} catch (e) {
console.error('Failed to fetch everclear config:', e);
logger.error('Failed to fetch everclear config', undefined, undefined, undefined, { error: e });
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 logger.error call won’t include the caught error because the 4th error parameter is undefined and Logger.error overwrites ctx.error. Pass jsonifyError(e as Error) as the 4th argument (or otherwise convert e to ErrorJson) instead of putting the error in the context.

Suggested change
logger.error('Failed to fetch everclear config', undefined, undefined, undefined, { error: e });
logger.error('Failed to fetch everclear config', undefined, undefined, jsonifyError(e as Error));

Copilot uses AI. Check for mistakes.
Comment on lines +37 to 38
(context.logger ?? logger).error('Error starting relayer :(', undefined, undefined, undefined, { error: err });
process.exit(1);
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.

Logger.error overwrites ctx.error with its explicit 4th parameter. Because the 4th parameter is undefined here, the error won’t be logged. Pass jsonifyError(err as Error) as the 4th argument and reserve the final context argument for extra fields.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to 13
const ethProviderLogger = new Logger({
level: 'debug',
name: 'eth-provider',
formatters: {
level: (label) => ({ level: label.toUpperCase() }),
},
});

import { parseError, RpcError, ServerError, StallTimeout } from '../../errors';
import { ISigner, ReadTransaction, WriteTransaction, ITransactionReceipt, ITransactionResponse, IBlock } from '../../types';
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.

There’s an import statement after executable code (const ethProviderLogger = ...). TypeScript/ESM requires all imports to be at the top level before other statements, so this will not compile. Move the ethProviderLogger initialization below the last import (or convert the later imports into the initial import block).

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +88
(context.logger ?? logger).error(
'Error setup context Watcher! D: Who could have done this?',
requestContext,
methodContext,
undefined,
{ error },
);
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.

Same issue here: { error } is provided in the context, but Logger.error(..., undefined, { error }) results in error being overwritten to undefined inside Logger.error. Use jsonifyError(error as Error) as the 4th argument (and add the jsonifyError import if needed).

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +86
(context.logger ?? logger).error(
'Error setup context Relayer! D: Who could have done this?',
requestContext,
methodContext,
undefined,
{ error },
);
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.

Same pattern here: the caught error is placed into the context object, but Logger.error sets error from its 4th argument (currently undefined), so it’s lost. Use jsonifyError(error as Error) as the 4th parameter (and import it if needed).

Copilot uses AI. Check for mistakes.
Comment on lines 45 to 47
} catch (e) {
console.error('Failed to fetch everclear config:', e);
logger.error('Failed to fetch everclear config', undefined, undefined, undefined, { error: e });
}
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 error log won’t include the caught exception because Logger.error overwrites ctx.error with its explicit 4th argument (here undefined). Pass a proper ErrorJson (e.g., jsonifyError(e as Error)) as the 4th parameter instead of { error: e } in the context.

Copilot uses AI. Check for mistakes.
Comment on lines 159 to 161
} catch (e: unknown) {
console.error('Error reading config file!', e);
logger.error('Error reading config file!', undefined, undefined, undefined, { error: e });
process.exit(1);
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.

Logger.error will overwrite ctx.error with its 4th argument. Because the 4th argument is undefined here, the exception won’t be logged. Pass jsonifyError(e as Error) as the 4th param (and use the final arg for extra fields).

Copilot uses AI. Check for mistakes.
everclearConfig = await getEverclearConfig(everclearConfigUrl);
} catch (e) {
console.error('Failed to fetch everclear config:', e);
logger.error('Failed to fetch everclear config', undefined, undefined, undefined, { error: e });
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 logger.error call won’t log the caught error because the 4th error parameter is undefined, and Logger.error overwrites ctx.error. Pass jsonifyError(e as Error) (or another ErrorJson) as the 4th argument instead of { error: e } in the context.

Suggested change
logger.error('Failed to fetch everclear config', undefined, undefined, undefined, { error: e });
logger.error('Failed to fetch everclear config', undefined, undefined, jsonifyError(e as Error));

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 19:49
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