0
這不會以彩色方式打印到控制檯。一切都是白色的。我一直在Google上搜索幾個小時。我正在運行Ubuntu 17.Winston將不會登錄顏色
// Logging with Winston
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 tsFormat =() => (new Date()).toLocaleTimeString()
const logDir = path.resolve(os.homedir(), '.test-logs')
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir)
}
const logger = createLogger({
format: format.combine(
format.splat(),
format.simple()
),
transports: [
new transports.Console({ timestamp: tsFormat, level: config.logLevel, 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
我沒有收到任何錯誤消息或任何內容。它只是白色的。