2017-06-04 04:35:47 +08:00
|
|
|
import * as winston from "winston";
|
|
|
|
|
|
|
|
declare module 'winston' {
|
2017-06-11 04:32:56 +08:00
|
|
|
interface LoggerInstance {
|
|
|
|
logFileName: string;
|
|
|
|
logFilePath: string;
|
|
|
|
}
|
2017-06-04 04:35:47 +08:00
|
|
|
}
|
|
|
|
|
2017-06-04 21:25:08 +08:00
|
|
|
export const winstonSettings = {
|
2017-06-11 04:32:56 +08:00
|
|
|
transports: [
|
|
|
|
new winston.transports.Console({
|
|
|
|
level: 'silly',
|
|
|
|
handleExceptions: true,
|
|
|
|
json: false,
|
|
|
|
colorize: true,
|
|
|
|
timestamp: function () {
|
|
|
|
return (new Date()).toLocaleString();
|
|
|
|
},
|
|
|
|
label: "innerLabel",
|
|
|
|
formatter: (options) => {
|
|
|
|
// Return string will be passed to logger.
|
|
|
|
return options.timestamp() + '[' + winston['config']['colorize'](options.level, options.level.toUpperCase()) + '] ' +
|
|
|
|
(undefined !== options.message ? options.message : '') +
|
|
|
|
(options.meta && Object.keys(options.meta).length ? '\n\t' + JSON.stringify(options.meta) : '' );
|
|
|
|
},
|
|
|
|
debugStdout: true
|
|
|
|
})
|
|
|
|
],
|
|
|
|
exitOnError: false
|
2017-06-04 21:25:08 +08:00
|
|
|
};
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
export const Logger = new winston.Logger(winstonSettings);
|