API-14: Changing logging to winston (#4)
Jenkins Production Deployment

Co-authored-by: Patrick Müller <patrick@mueller-patrick.tech>
Reviewed-on: #4
Co-authored-by: Patrick Müller <patrick@plutodev.de>
Co-committed-by: Patrick Müller <patrick@plutodev.de>
This commit was merged in pull request #4.
This commit is contained in:
2021-08-20 12:10:18 +00:00
parent 7265f92486
commit 915c2e7917
12 changed files with 2043 additions and 26 deletions
+52
View File
@@ -0,0 +1,52 @@
import * as appRoot from "app-root-path";
import * as winston from "winston";
const options = {
file_info: {
level: 'info',
filename: `${appRoot}/logs/app.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false
},
file_error: {
level: 'error',
filename: `${appRoot}/logs/error.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false
},
file_debug: {
level: 'debug',
filename: `${appRoot}/logs/debug.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false
},
console: {
level: 'debug',
handleExceptions: true,
json: false,
colorize: true
},
};
const logger: winston.Logger = winston.createLogger({
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [
new winston.transports.File(options.file_info),
new winston.transports.File(options.file_error),
new winston.transports.File(options.file_debug),
new winston.transports.Console(options.console)
],
exitOnError: false, // do not exit on handled exceptions
});
export default logger;