德朗6000透析机socket客户端程序通讯
chenyc
2025-02-21 d3973da8b1f1775a888a3a3fa90423a0e89b1425
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// logger.js
 
const winston = require('winston');
 
// 配置日志格式
const logger = winston.createLogger({
    level: 'info',
    format: winston.format.combine(
        winston.format.timestamp(),
        winston.format.printf(info => `${info.timestamp} [${info.level}] ${info.message}`)
    ),
    transports: [
        new winston.transports.Console({
            format: winston.format.combine(
                winston.format.colorize(),
                winston.format.printf(info => `${info.timestamp} [${info.level}] ${info.message}`)
            )
        }),
        new winston.transports.File({ filename: 'error.log', format: winston.format.printf(info => `${info.timestamp} [${info.level}] ${info.message}`) })
    ],
});
 
// 导出日志函数
module.exports = {
    info: (message) => logger.info(message),
    warn: (message) => logger.warn(message),
    error: (message) => logger.error(message)
};