Skip to content

Commit

Permalink
chore: replace info-level logs with debug (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
melisaguevara authored Nov 26, 2024
1 parent c90f73a commit f2b8e95
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 94 deletions.
3 changes: 2 additions & 1 deletion packages/indexer-api/src/database/database.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function connectToDatabase(
) {
try {
const database = await createDataSource(databaseConfig).initialize();
logger.info({
logger.debug({
at: "IndexerAPI#connectToDatabase",
message: "Postgres connection established",
});
Expand All @@ -16,6 +16,7 @@ export async function connectToDatabase(
logger.error({
at: "IndexerAPI#connectToDatabase",
message: "Unable to connect to database",
notificationPath: "across-indexer-error",
error,
});
throw error;
Expand Down
12 changes: 7 additions & 5 deletions packages/indexer-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ async function initializeRedis(

return new Promise<Redis>((resolve, reject) => {
redis.on("ready", () => {
logger.info({
at: "Indexer-API",
logger.debug({
at: "IndexerAPI#initializeRedis",
message: "Redis connection established",
config,
});
Expand All @@ -28,8 +28,9 @@ async function initializeRedis(

redis.on("error", (err) => {
logger.error({
at: "Indexer-API",
at: "IndexerAPI#initializeRedis",
message: "Redis connection failed",
notificationPath: "across-indexer-error",
error: err,
});
reject(err);
Expand All @@ -42,7 +43,7 @@ export async function connectToDatabase(
) {
try {
const database = await createDataSource(databaseConfig).initialize();
logger.info({
logger.debug({
at: "IndexerAPI#connectToDatabase",
message: "Postgres connection established",
});
Expand All @@ -51,6 +52,7 @@ export async function connectToDatabase(
logger.error({
at: "IndexerAPI#connectToDatabase",
message: "Unable to connect to database",
notificationPath: "across-indexer-error",
error,
});
throw error;
Expand Down Expand Up @@ -102,8 +104,8 @@ export async function Main(
const app = ExpressApp(allRouters);

logger.info({
at: "IndexerAPI#Main",
message: `Starting indexer api on port ${port}`,
at: "main.ts",
});
void (await new Promise((res) => {
app.listen(port, () => res(app));
Expand Down
3 changes: 2 additions & 1 deletion packages/indexer-database/src/utils/BaseRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class BaseRepository {
.values(data)
.returning("*")
.execute();
this.logger.info({
this.logger.debug({
at: "BaseRepository#insert",
message: `Saved ${data.length} ${repository.metadata.name} events`,
});
Expand All @@ -30,6 +30,7 @@ export class BaseRepository {
this.logger.error({
at: "BaseRepository#insert",
message: `There was an error while saving ${repository.metadata.name} events`,
notificationPath: "across-indexer-error",
error,
});
if (throwError || this.throwError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export class AcrossIndexerManager {

private startHubPoolIndexer() {
if (!this.config.enableHubPoolIndexer) {
this.logger.warn("Hub pool indexer is disabled");
this.logger.warn({
at: "Indexer#AcrossIndexerManager#startHubPoolIndexer",
message: "Hub pool indexer is disabled",
});
return;
}
const hubPoolIndexerDataHandler = new HubPoolIndexerDataHandler(
Expand Down Expand Up @@ -120,7 +123,10 @@ export class AcrossIndexerManager {
this.spokePoolIndexers = spokePoolIndexers;

if (this.spokePoolIndexers.length === 0) {
this.logger.warn("No spoke pool indexers to start");
this.logger.warn({
at: "Indexer#AcrossIndexerManager#startSpokePoolIndexers",
message: "No spoke pool indexers to start",
});
return;
}
return Promise.all(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
blockRange: BlockRange,
lastFinalisedBlock: number,
) {
this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Start processing block range ${this.getDataIdentifier()}`,
blockRange,
lastFinalisedBlock,
Expand All @@ -64,8 +64,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
let events: FetchEventsResult;

if (this.cachedFetchEventsResult) {
this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Using cached events for ${this.getDataIdentifier()}`,
});
events = this.cachedFetchEventsResult;
Expand All @@ -74,8 +74,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
this.cachedFetchEventsResult = events;
}

this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Fetched events ${this.getDataIdentifier()}`,
events: {
proposedRootBundleEvents: events.proposedRootBundleEvents.length,
Expand All @@ -88,8 +88,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
identifier: this.getDataIdentifier(),
});
await this.storeEvents(events, lastFinalisedBlock);
this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Finished processing block range ${this.getDataIdentifier()}`,
blockRange,
lastFinalisedBlock,
Expand Down
14 changes: 8 additions & 6 deletions packages/indexer/src/data-indexing/service/Indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export class Indexer {
}

if (!blockRangeResult?.blockRange) {
this.logger.info({
at: "Indexer::start",
this.logger.debug({
at: "Indexer#start",
message: `No new blocks to process ${this.dataHandler.getDataIdentifier()}`,
blockRangeResult,
dataIdentifier: this.dataHandler.getDataIdentifier(),
Expand All @@ -70,8 +70,10 @@ export class Indexer {
blockRangeProcessedSuccessfully = true;
} catch (error) {
this.logger.error({
at: "Indexer::start",
at: "Indexer#start",
message: "Error processing block range",
notificationPath: "across-indexer-error",
blockRangeResult,
dataIdentifier: this.dataHandler.getDataIdentifier(),
error,
});
Expand All @@ -80,8 +82,8 @@ export class Indexer {
if (!blockRangeResult?.isBackfilling) {
await across.utils.delay(this.config.loopWaitTimeSeconds);
} else {
this.logger.info({
at: "Indexer::start",
this.logger.debug({
at: "Indexer#start",
message: `Skip delay ${this.dataHandler.getDataIdentifier()}. Backfill in progress...`,
dataIdentifier: this.dataHandler.getDataIdentifier(),
});
Expand All @@ -96,7 +98,7 @@ export class Indexer {
*/
public stopGracefully() {
this.logger.info({
at: "Indexer::stopGracefully",
at: "Indexer#stopGracefully",
message: `Requesting indexer ${this.dataHandler.getDataIdentifier()} to be stopped`,
});
this.stopRequested = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class SpokePoolIndexerDataHandler implements IndexerDataHandler {
blockRange: BlockRange,
lastFinalisedBlock: number,
) {
this.logger.info({
at: "SpokePoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#SpokePoolIndexerDataHandler#processBlockRange",
message: `Processing block range ${this.getDataIdentifier()}`,
blockRange,
lastFinalisedBlock,
Expand All @@ -91,8 +91,8 @@ export class SpokePoolIndexerDataHandler implements IndexerDataHandler {
).reduce((acc, speedUps) => {
return acc + Object.values(speedUps).length;
}, 0);
this.logger.info({
at: "SpokePoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#SpokePoolIndexerDataHandler#processBlockRange",
message: `Found events for ${this.getDataIdentifier()}`,
events: {
v3FundsDepositedEvents: events.v3FundsDepositedEvents.length,
Expand Down
3 changes: 2 additions & 1 deletion packages/indexer/src/database/database.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function connectToDatabase(
) {
try {
const database = await createDataSource(databaseConfig).initialize();
logger.info({
logger.debug({
at: "Indexer#connectToDatabase",
message: "Postgres connection established",
});
Expand All @@ -16,6 +16,7 @@ export async function connectToDatabase(
logger.error({
at: "Indexer#connectToDatabase",
message: "Unable to connect to database",
notificationPath: "across-indexer-error",
error,
});
throw error;
Expand Down
15 changes: 8 additions & 7 deletions packages/indexer/src/generics/BaseIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export abstract class BaseIndexer {
private readonly name: string,
) {
this.logger.debug({
at: "BaseIndexer#constructor",
at: "Indexer#BaseIndexer#constructor",
message: `Instantiated indexer ${name}`,
});
}
Expand All @@ -25,8 +25,8 @@ export abstract class BaseIndexer {
* @param delay The delay in seconds between each iteration of the indexer
*/
public async start(delay: number): Promise<void> {
this.logger.info({
at: "BaseIndexer#start",
this.logger.debug({
at: "Indexer#BaseIndexer#start",
message: `Starting indexer ${this.name}`,
});

Expand All @@ -35,8 +35,9 @@ export abstract class BaseIndexer {
await this.initialize();
} catch (e) {
this.logger.error({
at: "BaseIndexer#start",
at: "Indexer#BaseIndexer#start",
message: `Failed to initialize ${this.name}`,
notificationPath: "across-indexer-error",
error: (e as unknown as Error).message,
});
return;
Expand All @@ -48,8 +49,8 @@ export abstract class BaseIndexer {
await across.utils.delay(delay);
} while (!this.stopRequested);

this.logger.info({
at: "BaseIndexer#start",
this.logger.debug({
at: "Indexer#BaseIndexer#start",
message: `Ended halted ${this.name}`,
});
}
Expand All @@ -60,7 +61,7 @@ export abstract class BaseIndexer {
*/
public stop(): void {
this.logger.info({
at: "BaseIndexer#stop",
at: "Indexer#BaseIndexer#stop",
message: `Requesting indexer ${this.name} to be stopped`,
});
this.stopRequested = true;
Expand Down
9 changes: 5 additions & 4 deletions packages/indexer/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function initializeRedis(

return new Promise<Redis>((resolve, reject) => {
redis.on("ready", () => {
logger.info({
logger.debug({
at: "Indexer#initializeRedis",
message: "Redis connection established",
config,
Expand All @@ -42,6 +42,7 @@ async function initializeRedis(
logger.error({
at: "Indexer#initializeRedis",
message: "Redis connection failed",
notificationPath: "across-indexer-error",
error: err,
});
reject(err);
Expand All @@ -50,7 +51,7 @@ async function initializeRedis(
}

export async function Main(config: parseEnv.Config, logger: winston.Logger) {
const { redisConfig, postgresConfig, hubChainId } = config;
const { redisConfig, postgresConfig } = config;
const redis = await initializeRedis(redisConfig, logger);
const redisCache = new RedisCache(redis);
const postgres = await connectToDatabase(postgresConfig, logger);
Expand Down Expand Up @@ -138,9 +139,9 @@ export async function Main(config: parseEnv.Config, logger: winston.Logger) {
}
});

logger.info({
message: "Running indexers",
logger.debug({
at: "Indexer#Main",
message: "Running indexers",
});
// start all indexers in parallel, will wait for them to complete, but they all loop independently
const [bundleServicesManagerResults, acrossIndexerManagerResult] =
Expand Down
16 changes: 9 additions & 7 deletions packages/indexer/src/services/BundleBuilderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export class BundleBuilderService extends BaseIndexer {
// of heap memory errors from needing to aggregate too much historical data
// from all the chains.
if (!(await this.isCloseEnoughToHead(lastExecutedBundle.proposal))) {
this.logger.info({
at: "BundleBuilder#Processor#indexerLogic",
this.logger.debug({
at: "Indexer#BundleBuilderService#indexerLogic",
message: "Last executed bundle is too far from head, skipping",
lastExecutedBundleBlock: lastExecutedBundle.proposal.blockNumber,
});
Expand All @@ -82,8 +82,8 @@ export class BundleBuilderService extends BaseIndexer {
this.handleHubBalanceAggregation(lastExecutedBundle),
]);

this.logger.info({
at: "BundleBuilderService#indexerLogic",
this.logger.debug({
at: "Indexer#BundleBuilderService#indexerLogic",
message: "Bundle builder loop completed",
currentLoopResult: currentLoopResult.status,
proposedLoopResult: proposedLoopResult.status,
Expand Down Expand Up @@ -171,9 +171,10 @@ export class BundleBuilderService extends BaseIndexer {
// Confirm that our current bundle data is not empty
if (!currentBundleData || currentBundleData.length === 0) {
this.logger.error({
at: "BundleBuilder#Processor#handleHubBalanceAggregation",
at: "Indexer#BundleBuilderService#handleHubBalanceAggregation",
message:
"No current bundle data found. Ensure that the current bundle loop has been run.",
notificationPath: "across-indexer-error",
l1Token,
});
return;
Expand Down Expand Up @@ -296,7 +297,7 @@ export class BundleBuilderService extends BaseIndexer {
// If no proposed bundle is found, skip the rest of the logic
if (!utils.isDefined(lastProposedBundle)) {
this.logger.debug({
at: "BundleBuilder#Processor#handleProposedBundleLoop",
at: "Indexer#BundleBuilderService#handleProposedBundleLoop",
message: "No proposed bundles found, skipping.",
});
// Clear the cache so that we don't have any stale data
Expand Down Expand Up @@ -373,8 +374,9 @@ export class BundleBuilderService extends BaseIndexer {
// an ample lookback range
if (!historicalProposal) {
this.logger.error({
at: "BundleBuilder#Processor#callRange",
at: "Indexer#BundleBuilderService#callRange",
message: "No historical proposal found",
notificationPath: "across-indexer-error",
});
throw new Error("No historical proposal found");
}
Expand Down
Loading

0 comments on commit f2b8e95

Please sign in to comment.