feat: Logins log for Fail2Ban (#986)

* login logs and output

* fix(merge)

* fix(wiston) unistall

* fix(winston) installation in api

* fix(logger) new module
This commit is contained in:
Marco Beretta 2023-09-24 18:18:10 +02:00 committed by GitHub
parent 7c0379ba51
commit 1bf6c259b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 198 additions and 27 deletions

View file

@ -1,23 +1,4 @@
const pino = require('pino');
const logger = pino({
level: 'info',
redact: {
paths: [
// List of Paths to redact from the logs (https://getpino.io/#/docs/redaction)
'env.OPENAI_API_KEY',
'env.BINGAI_TOKEN',
'env.CHATGPT_TOKEN',
'env.MEILI_MASTER_KEY',
'env.GOOGLE_CLIENT_SECRET',
'env.JWT_SECRET',
'env.JWT_SECRET_DEV',
'env.JWT_SECRET_PROD',
'newUser.password',
], // See example to filter object class instances
censor: '***', // Redaction character
},
});
const logger = require('./logger');
// Sanitize outside the logger paths. This is useful for sanitizing variables directly with Regex and patterns.
const redactPatterns = [

12
api/utils/logger.js Normal file
View file

@ -0,0 +1,12 @@
const winston = require('winston');
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: 'login-logs.log' }),
],
});
module.exports = logger;