Skip to content

Commit

Permalink
fix: change end-of-chain scan log message to debug instead of error (#…
Browse files Browse the repository at this point in the history
…652)

# Problem

"Latest finalized block encountered" error messages spam the log.

# Solution

Changed the log level to `debug`.
Went back & forth between this & `verbose`; ultimately decided that even
at the verbose level it's too spammy.
Different opinions welcome in the comments section.

## Steps to Verify:

1. Run any gateway service with `DEBUG=true` in the environment
2. Let the scan run & watch the log
3. Logs about the scan reaching end-of-chain should be logged at the
`[DEBUG]` level

Closes #643
  • Loading branch information
JoeCap08055 authored Oct 23, 2024
1 parent 0d82934 commit 4c993a4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
8 changes: 1 addition & 7 deletions libs/account-lib/src/utils/blockchain-scanner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface IBlockchainScanParameters {
}

export class EndOfChainError extends Error {}
export class NullScanError extends Error {}

function eventName({ event: { section, method } }: FrameSystemEventRecord) {
return `${section}.${method}`;
Expand Down Expand Up @@ -92,12 +91,7 @@ export abstract class BlockchainScannerService {
}
} catch (e: any) {
if (e instanceof EndOfChainError) {
this.logger.error(e.message);
return;
}

if (e instanceof NullScanError) {
this.logger.verbose(e.message);
this.logger.debug(e.message);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface IBlockchainScanParameters {
}

export class EndOfChainError extends Error {}
export class NullScanError extends Error {}
export class SkipBlockError extends Error {}

function eventName({ event: { section, method } }: FrameSystemEventRecord) {
Expand Down Expand Up @@ -99,12 +98,7 @@ export abstract class BlockchainScannerService {
}
} catch (e) {
if (e instanceof EndOfChainError) {
this.logger.error(e.message);
return;
}

if (e instanceof NullScanError) {
this.logger.verbose(e.message);
this.logger.debug(e.message);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion libs/content-watcher-lib/src/scanner/scanner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class ScannerService implements OnApplicationBootstrap, OnApplicationShut
const currentBlockNumber = await this.getNextBlockNumber();
const currentBlockHash = await this.blockchainService.getBlockHash(currentBlockNumber);
if (currentBlockHash.isEmpty) {
this.logger.log(
this.logger.debug(
`No new blocks to scan @ block number ${currentBlockNumber}; pausing scan until next interval`,
);
break;
Expand Down
8 changes: 1 addition & 7 deletions libs/graph-lib/src/utils/blockchain-scanner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface IBlockchainScanParameters {
}

export class EndOfChainError extends Error {}
export class NullScanError extends Error {}
export class SkipBlockError extends Error {}

function eventName({ event: { section, method } }: FrameSystemEventRecord) {
Expand Down Expand Up @@ -99,12 +98,7 @@ export abstract class BlockchainScannerService {
}
} catch (e) {
if (e instanceof EndOfChainError) {
this.logger.error(e.message);
return;
}

if (e instanceof NullScanError) {
this.logger.verbose(e.message);
this.logger.debug(e.message);
return;
}

Expand Down

0 comments on commit 4c993a4

Please sign in to comment.