1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-14 11:23:17 +02:00
pigallery2/backend/Logger.ts

34 lines
955 B
TypeScript

import * as winston from "winston";
declare module 'winston' {
interface LoggerInstance {
logFileName: string;
logFilePath: string;
}
}
export const winstonSettings = {
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
};
export const Logger = new winston.Logger(winstonSettings);