DocsGood First IssueHelp Wanted
Description
I created a shared logger successfully, but it prints all white, even though I've set colorize to true. And as a test, My Label successfully prints out in red.
// Logging with Winston
const { red } = require('colors')
const os = require('os')
const fs = require('fs')
const path = require('path')
const config = require('../data/config/config')
const winston = require('winston')
const { createLogger, format, transports } = winston
const { combine, timestamp, label, printf } = format
const tsFormat = () => (new Date()).toLocaleTimeString()
const myFormat = printf(info => {
return `${info.timestamp} [${info.label}] ${info.level}: ${info.message}`
})
const logDir = path.resolve(os.homedir(), '.curator-server')
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir)
}
const logger = createLogger({
format: combine(
label({ label: red('My Label') }),
timestamp(),
myFormat
),
transports: [
new transports.Console({ level: config.logLevel, humanReadableUnhandledException: true, colorize: true }),
new transports.File({ filename: path.resolve(logDir, 'info.log'), level: 'info' }),
new transports.File({ filename: path.resolve(logDir, 'error.log'), level: 'error' })
]
})
module.exports = logger