Skip to content

Commit

Permalink
trace error by info
Browse files Browse the repository at this point in the history
  • Loading branch information
JSHan94 committed Dec 19, 2023
1 parent 23d6562 commit c26be80
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 17 deletions.
5 changes: 2 additions & 3 deletions bots/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { LCDClient } from '@initia/initia.js';
import * as dotenv from 'dotenv';

const envFile = process.env.NODE_ENV === 'test'
? `.env`
: `.env.${process.env.WORKER_NAME}`;
const envFile =
process.env.NODE_ENV === 'test' ? `.env` : `.env.${process.env.WORKER_NAME}`;

console.log(envFile);
dotenv.config({ path: envFile });
Expand Down
6 changes: 5 additions & 1 deletion bots/src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ function createLogger(name: string) {
}
}

const message = info.stack
? `${info.message}\n${info.stack}`
: info.message;

const log = `${getDateString()} [${
level ? level : info.level
} - ${name}]: ${info.message}`;
} - ${name}]: ${message}`;

return log;
});
Expand Down
10 changes: 5 additions & 5 deletions bots/src/lib/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class RPCSocket {

// eslint-disable-next-line
protected onError(error): void {
this.logger.error(`${this.constructor.name} websocket: `, error);
this.logger.info(`${this.constructor.name} websocket: `, error);
}

// eslint-disable-next-line
Expand All @@ -139,7 +139,7 @@ export class RPCSocket {
try {
data = JSON.parse(raw);
} catch (error) {
this.logger.error(`${this.constructor.name}: JSON parse error ${raw}`);
this.logger.info(`${this.constructor.name}: JSON parse error ${raw}`);
return;
}

Expand All @@ -150,7 +150,7 @@ export class RPCSocket {
);
}
} catch (error) {
this.logger.error(error);
this.logger.info(error);
}

this.alive();
Expand Down Expand Up @@ -223,7 +223,7 @@ export class RPCClient {
});

if (!blockchainResult) {
this.logger.error('failed get blockchain from rpc');
this.logger.info('failed get blockchain from rpc');
return null;
}

Expand All @@ -237,7 +237,7 @@ export class RPCClient {
});

if (!blockBulksResult) {
this.logger.error('failed get block bulks from rpc');
this.logger.info('failed get block bulks from rpc');
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion bots/src/worker/batchSubmitter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function runBot(): Promise<void> {
})
);
} catch (err) {
logger.error(err);
logger.info(err);
stopBatch();
}
}
Expand Down
2 changes: 1 addition & 1 deletion bots/src/worker/bridgeExecutor/L1Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class L1Monitor extends Monitor {
const errMsg = err.response?.data
? JSON.stringify(err.response?.data)
: err.toString();
this.logger.error(
this.logger.info(
`Failed to submit tx in height: ${this.currentHeight}\nMsg: ${stringfyMsgs}\nError: ${errMsg}`
);

Expand Down
2 changes: 1 addition & 1 deletion bots/src/worker/bridgeExecutor/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export abstract class Monitor {
});
} catch (err) {
this.stop();
this.logger.error(err);
this.logger.info(err);
throw new Error(`Error in ${this.name()} ${err}`);
} finally {
await Bluebird.delay(INTERVAL_MONITOR);
Expand Down
2 changes: 1 addition & 1 deletion bots/src/worker/bridgeExecutor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function runBot(): Promise<void> {
})
);
} catch (err) {
logger.error(err);
logger.info(err);
stopExecutor();
}
}
Expand Down
2 changes: 1 addition & 1 deletion bots/src/worker/challenger/challenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export class Challenger {
await this.deleteOutputProposal(outputIndex);
}

await notifySlack(buildChallengerNotification(challengedOutput))
await notifySlack(buildChallengerNotification(challengedOutput));
process.exit();
}
}
2 changes: 1 addition & 1 deletion bots/src/worker/challenger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function runBot(): Promise<void> {
})
);
} catch (err) {
logger.error(err);
logger.info(err);
stopChallenger();
}
}
Expand Down
2 changes: 1 addition & 1 deletion bots/src/worker/outputSubmitter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function runBot(): Promise<void> {
})
);
} catch (err) {
logger.error(err);
logger.info(err);
stopOutput();
}
}
Expand Down
2 changes: 1 addition & 1 deletion bots/src/worker/outputSubmitter/outputSubmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class OutputSubmitter {
);
await delay(INTERVAL_OUTPUT);
} else {
logger.error(err);
logger.info(err);
this.stop();
}
}
Expand Down

0 comments on commit c26be80

Please sign in to comment.