Skip to content

Commit dcb47d1

Browse files
committed
fix: replaced console logs with logger in adapters and agents
1 parent 8caa226 commit dcb47d1

File tree

23 files changed

+283
-130
lines changed

23 files changed

+283
-130
lines changed

packages/adapters/cache/src/lib/caches/cache.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import Redis from 'ioredis';
2+
import { Logger } from '@chimera-monorepo/utils';
23

34
import { CacheParams, RedisClearFailure } from '../entities';
45

56
/**
67
* @classdesc Manages storage, updates, and retrieval of a set of data determined by use-case.
78
*/
9+
const logger = new Logger({
10+
level: 'info',
11+
name: 'cache',
12+
formatters: {
13+
level: (label) => ({ level: label.toUpperCase() }),
14+
},
15+
});
16+
817
export abstract class Cache {
918
protected readonly data!: Redis;
1019

@@ -22,7 +31,7 @@ export abstract class Cache {
2231
});
2332
// Handle Redis connection errors to prevent unhandled exceptions
2433
this.data.on('error', (err) => {
25-
console.error('Redis connection error:', err);
34+
logger.error('Redis connection error', undefined, undefined, undefined, { error: err });
2635
});
2736
}
2837
}

packages/adapters/chainservice/src/aggregator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class RpcProviderAggregator {
131131
* @returns The TransactionResponse.
132132
*/
133133
public async sendTransaction(transaction: OnchainTransaction) {
134-
console.log(`=== sendTransaction called with domain ${this.domain} ===`);
134+
this.logger.debug(`sendTransaction called with domain ${this.domain}`);
135135
this.checkSigner();
136136

137137
const toSend = {

packages/adapters/chainservice/src/dispatch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export class TransactionDispatch {
359359
* @returns A list of receipts or errors that occurred for each.
360360
*/
361361
public async send(minTx: WriteTransaction, context: RequestContext): Promise<ITransactionReceipt> {
362-
console.log(`=== DISPATCH SEND called for domain ${this.domain} ===`);
362+
this.logger.debug(`Dispatch send called for domain ${this.domain}`);
363363
const method = this.send.name;
364364
const { requestContext, methodContext } = createLoggingContext(method, context);
365365
const txsId = getUuid();
@@ -544,7 +544,7 @@ export class TransactionDispatch {
544544
* @param transaction - OnchainTransaction object to modify based on submit result.
545545
*/
546546
private async submit(transaction: OnchainTransaction) {
547-
console.log(`=== DISPATCH SUBMIT called for domain ${this.domain} ===`);
547+
this.logger.debug(`Dispatch submit called for domain ${this.domain}`);
548548
const method = this.submit.name;
549549
const { requestContext, methodContext } = createLoggingContext(method, transaction.context);
550550
this.logger.debug('Method start', requestContext, methodContext, {
@@ -562,7 +562,7 @@ export class TransactionDispatch {
562562

563563
// Send the tx.
564564
try {
565-
console.log(`=== DISPATCH SUBMIT about to call sendTransaction ===`);
565+
this.logger.debug('Dispatch submit about to call sendTransaction');
566566
const response = await this.rpcProvider.sendTransaction(transaction);
567567
// Add this response to our local response history.
568568
if (transaction.hashes.includes(response.hash)) {

packages/adapters/chainservice/src/shared/rpc/eth/provider.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
import { EverclearError, delay, domainToChainId, parseHostname, ERC20Abi } from '@chimera-monorepo/utils';
1+
import { EverclearError, Logger, delay, domainToChainId, parseHostname, ERC20Abi } from '@chimera-monorepo/utils';
22
import { chainWrapper, type PublicClient } from '@chimera-monorepo/utils';
3-
43
import { parseError, RpcError, ServerError, StallTimeout } from '../../errors';
54
import { ISigner, ReadTransaction, WriteTransaction, ITransactionReceipt, ITransactionResponse, IBlock } from '../../types';
65
import { RpcProvider } from '..';
76
import { EthWallet } from './wallet';
87

8+
const ethProviderLogger = new Logger({
9+
level: 'debug',
10+
name: 'eth-provider',
11+
formatters: {
12+
level: (label) => ({ level: label.toUpperCase() }),
13+
},
14+
});
15+
916
// TODO: Wrap metrics in a type, and add a getter for it for logging purposes (after sync() calls, for example)
1017
// TODO: Should be a multiton mapped by URL (such that no duplicate instances are created).
1118
/**
@@ -144,7 +151,7 @@ class BaseSyncProvider {
144151
try {
145152
sendTimestamp = Date.now();
146153
this.cpsTimestamps.push(sendTimestamp);
147-
console.log(`=== ETH PROVIDER SEND called with method: ${method}, domain: ${this.domain}, params:`, params);
154+
this.debugLog('ETH_PROVIDER_SEND', method, this.domain, params);
148155
return await Promise.race(
149156
[
150157
new Promise(async (resolve, reject) => {
@@ -248,8 +255,7 @@ class BaseSyncProvider {
248255

249256
private debugLog(message: string, ...args: unknown[]) {
250257
if (this.debugLogging) {
251-
// eslint-disable-next-line
252-
console.log(`[${Date.now()}]`, `(${this.name})`, message, ...args);
258+
ethProviderLogger.debug(`(${this.name}) ${message}`, undefined, undefined, { args });
253259
}
254260
}
255261

0 commit comments

Comments
 (0)