Skip to content

Commit

Permalink
refactor: use nanocolors instead of chalk (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW authored Oct 1, 2021
1 parent 4159c65 commit d4add03
Show file tree
Hide file tree
Showing 3 changed files with 8,047 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/log.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { Console } = require('console');
const chalk = require('chalk');
const nanocolors = require('nanocolors');

const TRACE = 10;
const DEBUG = 20;
Expand Down Expand Up @@ -55,14 +55,14 @@ class Logger {
const str = new Date().toISOString().substring(11, 23) + ' ';

if (level === TRACE || level >= WARN) {
process.stderr.write(chalk[LEVEL_COLORS[DEBUG]](str));
process.stderr.write(nanocolors[LEVEL_COLORS[DEBUG]](str));
} else {
process.stdout.write(chalk[LEVEL_COLORS[DEBUG]](str));
process.stdout.write(nanocolors[LEVEL_COLORS[DEBUG]](str));
}
}

if (level >= this.level) {
const str = chalk[LEVEL_COLORS[level]](LEVEL_NAMES[level]) + ' ';
const str = nanocolors[LEVEL_COLORS[level]](LEVEL_NAMES[level]) + ' ';
if (level === TRACE || level >= WARN) {
process.stderr.write(str);
} else {
Expand Down
Loading

0 comments on commit d4add03

Please sign in to comment.