mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
33 lines
751 B
TypeScript
33 lines
751 B
TypeScript
import winston from 'winston';
|
|
import config from '../config';
|
|
|
|
const transports = [];
|
|
if (process.env.NODE_ENV !== 'development') {
|
|
transports.push(new winston.transports.Console());
|
|
} else {
|
|
transports.push(
|
|
new winston.transports.Console({
|
|
format: winston.format.combine(
|
|
winston.format.cli(),
|
|
winston.format.splat(),
|
|
),
|
|
}),
|
|
);
|
|
}
|
|
|
|
const LoggerInstance = winston.createLogger({
|
|
level: config.logs.level,
|
|
levels: winston.config.npm.levels,
|
|
format: winston.format.combine(
|
|
winston.format.timestamp({
|
|
format: 'YYYY-MM-DD HH:mm:ss',
|
|
}),
|
|
winston.format.errors({ stack: true }),
|
|
winston.format.splat(),
|
|
winston.format.json(),
|
|
),
|
|
transports,
|
|
});
|
|
|
|
export default LoggerInstance;
|