1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/backend/Logger.ts

27 lines
914 B
TypeScript
Raw Normal View History

2018-03-30 15:30:30 -04:00
import * as winston from 'winston';
2017-06-04 15:25:08 +02:00
export const winstonSettings = {
transports: [
2018-11-30 15:36:42 +01:00
new winston.transports.Console(<any>{
level: process.env.NODE_ENV === 'production' ? 'info' : 'silly',
handleExceptions: true,
json: false,
colorize: true,
timestamp: function () {
return (new Date()).toLocaleString();
},
2018-03-30 15:30:30 -04:00
label: 'innerLabel',
2018-11-30 15:36:42 +01:00
formatter: (options: any) => {
// Return string will be passed to logger.
2018-11-30 15:36:42 +01:00
return options.timestamp() + '[' + (<any>winston)['config']['colorize'](options.level, options.level.toUpperCase()) + '] ' +
(undefined !== options.message ? options.message : '') +
2018-03-30 15:30:30 -04:00
(options.meta && Object.keys(options.meta).length ? '\n\t' + JSON.stringify(options.meta) : '');
},
debugStdout: true
})
],
exitOnError: false
2017-06-04 15:25:08 +02:00
};
2018-11-30 15:36:42 +01:00
export const Logger = new (<any>winston).Logger(winstonSettings);