cordova-11/cmd/utils/logger.js

23 lines
751 B
JavaScript
Raw Permalink Normal View History

2022-05-24 14:49:24 +08:00
const { createLogger, format, transports } = require('winston');
const path = require('path');
const env = process.env.NODE_ENV || 'development';
const logger = createLogger({
level: env === 'production' ? 'info' : 'debug',
format: format.combine(
format.label({ label: path.basename(process.mainModule.filename) }),
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' })
),
transports: [
new transports.Console({
format: format.combine(
format.colorize(),
format.printf(
info =>
`${info.timestamp} ${info.level} [${info.label}]: ${info.message}`
)
)
}),
]
});
module.exports = logger;