Skip to content

Commit

Permalink
implement fatal logger method
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Peveler <[email protected]>
  • Loading branch information
MasterOdin committed Nov 4, 2020
1 parent f9b991b commit 044eb95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions logger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export declare function debug(msg: any): void;
export declare function info(msg: any): void;
export declare function warn(msg: any): void;
export declare function error(msg: any): void;
export declare function fatal(msg: any): void;
9 changes: 9 additions & 0 deletions logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,12 @@ module.exports.warn = (msg) => {
module.exports.error = (msg) => {
this.logExpression(msg, -1, color.red('[error]'));
};

/**
* Log fatal message
*
* @param {*} msg
*/
module.exports.fatal = (msg) => {
this.logExpression(msg, -2, color.bold.red('[FATAL]'))
}
7 changes: 7 additions & 0 deletions logger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,11 @@ describe('logger', () => {
expect(logOutput[0]).toContain('[error]');
expect(logOutput[0]).toMatch(/test$/);
});

test('fatal', () => {
logger.fatal('test');
expect(logOutput).toHaveLength(1);
expect(logOutput[0]).toContain('[FATAL]');
expect(logOutput[0]).toMatch(/test$/);
})
});

0 comments on commit 044eb95

Please sign in to comment.