Skip to content

Commit

Permalink
refactor: remove templating from FATAL logs
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Jan 9, 2025
1 parent 47d7b14 commit ebf5534
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/logger/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,10 @@ export function validateLogLevel(
},
],
});
logger.fatal(`${logLevelToCheck} is not a valid log level. terminating...`);
logger.fatal(
{ logLevel: logLevelToCheck },
'Invalid log level. terminating...',
);
process.exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/workers/global/config/parse/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function getConfig(env: NodeJS.ProcessEnv): Promise<AllConfig> {
config = await getParsedContent(configFile);
} catch (err) {
if (err instanceof SyntaxError || err instanceof TypeError) {
logger.fatal(`Could not parse config file \n ${err.stack!}`);
logger.fatal({ error: err.stack }, 'Could not parse config file');
process.exit(1);
} else if (err instanceof ReferenceError) {
logger.fatal(
Expand Down
4 changes: 2 additions & 2 deletions lib/workers/global/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ export async function start(): Promise<number> {
await exportStats(config);
} catch (err) /* istanbul ignore next */ {
if (err.message.startsWith('Init: ')) {
logger.fatal(err.message.substring(6));
logger.fatal({ errorMessage: err.message.substring(6) }, 'Fatal error');
} else {
logger.fatal({ err }, `Fatal error: ${String(err.message)}`);
logger.fatal({ err, errorMessage: err.message }, 'Fatal error');
}
if (!config!) {
// return early if we can't parse config options
Expand Down

0 comments on commit ebf5534

Please sign in to comment.