Node基础如何深入掌握?
摘要:1、node本地化日志 本地化日志及按日期切割 const winston = require('winston'); require('winston-daily
1、node本地化日志
//本地化日志及按日期切割
const winston = require('winston');
require('winston-daily-rotate-file');
var transport = new winston.transports.DailyRotateFile({
filename: 'logs/console-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});
const logConfiguration = {
transports: [
transport
// new winston.transports.File({
// filename: 'logs/console.log'
// })
],
format: winston.format.combine(
winston.format.label({
label: `HealthTimerTask `
}),
winston.format.timestamp({
format: 'MMM-DD-YYYY HH:mm:ss'
}),
winston.format.printf(info => `${info.level}: ${info.label}: ${[info.timestamp]}: ${info.message}`),
)
};
const logger = winston.createLogger(logConfiguration);
module.exports = logger
2、node表格处理
npm install excel-report
var nodeExcel = require('excel-export');
//处理excel
var conf = {}
conf.stylesXmlFile = "styles.xml";
conf.cols = [{
caption: '姓名',
type: 'string',
beforeCellWrite: function (row, cellData) {
console.log(row)
console.log(cellData)
return cellData;
},
width: 18.7109375
},
{
caption: '身份证',
type: 'string',
beforeCellWrite: function (row, cellData) {
return cellData;
},
width: 28.7109375
},
{
caption: '电话',
type: 'string',
beforeCellWrite: function (row, cellData) {
return cellData;
},
width: 18.7109375
},
{
caption: '持卡人信息',
type: 'string',
beforeCellWrite: function (row, cellData) {
return cellData;
},
width: 18.7109375
},
{
