diff --git a/benchmark/format-message.js b/benchmark/format-message.js index 80aaa4b..09c0730 100644 --- a/benchmark/format-message.js +++ b/benchmark/format-message.js @@ -3,7 +3,15 @@ const benchmark = require('benchmark') const messageFormatFactory = require('../lib/messageFormatFactory') -const formatMessageColorized = messageFormatFactory(true) +const colors = { + 60: 'red', + 50: 'red', + 40: 'yellow', + 30: 'green', + 20: 'blue', + 10: 'cyan' +} +const formatMessageColorized = messageFormatFactory(true, colors, true) const log = { time: Date.now(), level: 30, diff --git a/lib/messageFormatFactory.js b/lib/messageFormatFactory.js index 8714304..6eaa6a6 100644 --- a/lib/messageFormatFactory.js +++ b/lib/messageFormatFactory.js @@ -3,12 +3,10 @@ const formatDate = require('./formatDate') const colorizerFactory = require('pino-pretty').colorizerFactory const messageFormatFactory = (levels, colors, useColors) => { - const customColors = - colors != null - ? Object.entries(colors).reduce((colors, [level, color]) => { - return [...colors, [level, color]] - }, []) - : undefined + let customColors + if (colors != null) { + customColors = Object.entries(colors) + } const colorizer = colorizerFactory(useColors, customColors) const levelLookUp = {