Skip to content

Commit

Permalink
feat: import getLogLevelName from roarr
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Nov 12, 2021
1 parent b27b3c3 commit 83e22ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"es6-error": "^4.1.1",
"liqe": "^1.2.1",
"prettyjson": "^1.2.1",
"roarr": "^7.4.0",
"roarr": "^7.6.0",
"socket.io-client": "^4.3.2",
"split2": "^4.1.0",
"throttle-debounce": "^3.0.1",
Expand Down
30 changes: 9 additions & 21 deletions src/factories/createLogFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import prettyjson from 'prettyjson';
import {
getLogLevelName,
} from 'roarr';
import type {
Message,
} from 'roarr';
Expand All @@ -11,31 +14,16 @@ import {
isRoarrLine,
} from '../utilities';

/* eslint-disable quote-props */
const logLevels = {
'10': 'TRACE',
'20': 'DEBUG',
'30': 'INFO',
'40': 'WARN',
'50': 'ERROR',
'60': 'FATAL',
};
/* eslint-enable */

export const createLogFormatter = (configuration: LogFormatterConfigurationType) => {
const chalk = configuration.chalk;

const logLevelColorMap = {
DEBUG: chalk.gray,
ERROR: chalk.red,
FATAL: chalk.red,
INFO: chalk.cyan,
TRACE: chalk.gray,
WARN: chalk.yellow,
};

const getLogLevelName = (logLevel: number): string => {
return logLevels[logLevel] || 'INFO';
debug: chalk.gray,
error: chalk.red,
fatal: chalk.red,
info: chalk.cyan,
trace: chalk.gray,
warn: chalk.yellow,
};

const formatMessage = (message: Message): string => {
Expand Down

0 comments on commit 83e22ef

Please sign in to comment.