Skip to content

Commit

Permalink
Switch from colors to chalk (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox authored Jan 10, 2022
1 parent 8b4e9cf commit 894a6fc
Show file tree
Hide file tree
Showing 4 changed files with 1,347 additions and 1,246 deletions.
18 changes: 9 additions & 9 deletions lib/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var util = require('util'),
colors = require('colors/safe'),
chalk = require('chalk'),
safeStringify = require('safe-json-stringify'),
serializeErr = require('serr'),
_ = require('lodash');
Expand Down Expand Up @@ -74,32 +74,32 @@ function formatDevTrace(level, context, message, args, err) {

switch (level) {
case 'DEBUG':
str = colors.grey(level);
str = chalk.grey(level);
break;
case 'INFO':
str = colors.blue(level) + ' '; // Pad to 5 chars
str = chalk.blue(level) + ' '; // Pad to 5 chars
break;
case 'WARN':
str = colors.yellow(level) + ' '; // Pad to 5 chars
str = chalk.yellow(level) + ' '; // Pad to 5 chars
break;
case 'ERROR':
str = colors.red(level);
str = chalk.red(level);
break;
case 'FATAL':
str = colors.red.bold(level);
str = chalk.red.bold(level);
break;
}
str += ' ' + mainMessage;

if (isErrorLoggingWithoutMessage) {
str += colorize(colors.gray, serializeErr(err).toString(printStack).substr(mainMessage.length));
str += colorize(chalk.gray, serializeErr(err).toString(printStack).substr(mainMessage.length));
} else if (err) {
str += '\n' + colorize(colors.gray, serializeErr(err).toString(printStack));
str += '\n' + colorize(chalk.gray, serializeErr(err).toString(printStack));
}

var localContext = _.omit(context, formatDevTrace.omit);
str += Object.keys(localContext).length ?
' ' + colorize(colors.gray, util.inspect(localContext)) :
' ' + colorize(chalk.gray, util.inspect(localContext)) :
'';

// pad all subsequent lines with as much spaces as "DEBUG " or "INFO " have
Expand Down
Loading

0 comments on commit 894a6fc

Please sign in to comment.