-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* perf: 延长获取地址订单信息事件, 保证商品已经开放购买 * feat: add log lib
- Loading branch information
Showing
5 changed files
with
196 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const winston = require('winston'); | ||
const { format } = winston; | ||
const { combine, timestamp, label, printf } = format; | ||
|
||
const myFormat = printf(({ level, message, timestamp }) => { | ||
return `${timestamp}-${level}: ${message}`; | ||
}); | ||
|
||
const logger = winston.createLogger({ | ||
level: 'info', | ||
format: combine( | ||
label('yuye'), | ||
timestamp({ | ||
format: 'HH:mm:ss' | ||
}), | ||
myFormat | ||
), | ||
defaultMeta: { service: 'yuye' }, | ||
transports: [ | ||
new winston.transports.File({ | ||
filename: './log/error.log', | ||
level: 'error' | ||
}), | ||
new winston.transports.File({ filename: './log/combined.log' }), | ||
new winston.transports.Console() | ||
] | ||
}); | ||
|
||
Object.assign(console, { | ||
log(...arg) { | ||
logger.info(arg.join('')); | ||
}, | ||
error(...arg) { | ||
logger.error(arg.join('')); | ||
}, | ||
info(...arg) { | ||
logger.info(arg.join('')); | ||
} | ||
}); | ||
|
||
|
||
module.exports = logger; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters