Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/adapters/cache/src/lib/caches/cache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import Redis from 'ioredis';
import { Logger, jsonifyError } from '@chimera-monorepo/utils';

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

/**
* @classdesc Manages storage, updates, and retrieval of a set of data determined by use-case.
*/
const logger = new Logger({
level: 'info',
name: 'cache',
formatters: {
level: (label) => ({ level: label.toUpperCase() }),
},
});

export abstract class Cache {
protected readonly data!: Redis;

Expand All @@ -22,7 +31,7 @@ export abstract class Cache {
});
// Handle Redis connection errors to prevent unhandled exceptions
this.data.on('error', (err) => {
console.error('Redis connection error:', err);
logger.error('Redis connection error', undefined, undefined, jsonifyError(err as Error));
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/chainservice/src/aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class RpcProviderAggregator {
* @returns The TransactionResponse.
*/
public async sendTransaction(transaction: OnchainTransaction) {
console.log(`=== sendTransaction called with domain ${this.domain} ===`);
this.logger.debug(`sendTransaction called with domain ${this.domain}`);
this.checkSigner();

const toSend = {
Expand Down
6 changes: 3 additions & 3 deletions packages/adapters/chainservice/src/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export class TransactionDispatch {
* @returns A list of receipts or errors that occurred for each.
*/
public async send(minTx: WriteTransaction, context: RequestContext): Promise<ITransactionReceipt> {
console.log(`=== DISPATCH SEND called for domain ${this.domain} ===`);
this.logger.debug(`Dispatch send called for domain ${this.domain}`);
const method = this.send.name;
const { requestContext, methodContext } = createLoggingContext(method, context);
const txsId = getUuid();
Expand Down Expand Up @@ -544,7 +544,7 @@ export class TransactionDispatch {
* @param transaction - OnchainTransaction object to modify based on submit result.
*/
private async submit(transaction: OnchainTransaction) {
console.log(`=== DISPATCH SUBMIT called for domain ${this.domain} ===`);
this.logger.debug(`Dispatch submit called for domain ${this.domain}`);
const method = this.submit.name;
const { requestContext, methodContext } = createLoggingContext(method, transaction.context);
this.logger.debug('Method start', requestContext, methodContext, {
Expand All @@ -562,7 +562,7 @@ export class TransactionDispatch {

// Send the tx.
try {
console.log(`=== DISPATCH SUBMIT about to call sendTransaction ===`);
this.logger.debug('Dispatch submit about to call sendTransaction');
const response = await this.rpcProvider.sendTransaction(transaction);
// Add this response to our local response history.
if (transaction.hashes.includes(response.hash)) {
Expand Down
16 changes: 11 additions & 5 deletions packages/adapters/chainservice/src/shared/rpc/eth/provider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { EverclearError, delay, domainToChainId, parseHostname, ERC20Abi } from '@chimera-monorepo/utils';
import { EverclearError, Logger, delay, domainToChainId, parseHostname, ERC20Abi } from '@chimera-monorepo/utils';
import { chainWrapper, type PublicClient } from '@chimera-monorepo/utils';

import { parseError, RpcError, ServerError, StallTimeout } from '../../errors';
import { ISigner, ReadTransaction, WriteTransaction, ITransactionReceipt, ITransactionResponse, IBlock } from '../../types';
import { RpcProvider } from '..';
import { EthWallet } from './wallet';

const ethProviderLogger = new Logger({
level: 'debug',
name: 'eth-provider',
formatters: {
level: (label) => ({ level: label.toUpperCase() }),
},
});

// TODO: Wrap metrics in a type, and add a getter for it for logging purposes (after sync() calls, for example)
// TODO: Should be a multiton mapped by URL (such that no duplicate instances are created).
/**
Expand Down Expand Up @@ -144,7 +151,7 @@ class BaseSyncProvider {
try {
sendTimestamp = Date.now();
this.cpsTimestamps.push(sendTimestamp);
console.log(`=== ETH PROVIDER SEND called with method: ${method}, domain: ${this.domain}, params:`, params);
this.debugLog('ETH_PROVIDER_SEND', method, this.domain, params);
return await Promise.race(
[
new Promise(async (resolve, reject) => {
Expand Down Expand Up @@ -248,8 +255,7 @@ class BaseSyncProvider {

private debugLog(message: string, ...args: unknown[]) {
if (this.debugLogging) {
// eslint-disable-next-line
console.log(`[${Date.now()}]`, `(${this.name})`, message, ...args);
ethProviderLogger.debug(`(${this.name}) ${message}`, undefined, undefined, { args });
}
}

Expand Down
Loading
Loading