This module is designed to modify the standard console methods, ensure that the messages are properly formatted for integration with the ELK, and provide middleware for Express to work seamlessly with these methods on the frontend:
const logsFormatter = require('@crowdin/logs-formatter');
logsFormatter.setup();
const app = express();
app.use(express.json({ limit: '50mb' }));
app.use(logsFormatter.expressMiddleware());
app.use(logsFormatter.contextResolverMiddleware());
console.log();
console.debug();
console.info();
console.warn();
console.trace();
console.error();
console.fatal();
setContext({ project: { id: 1, identifier: 'newproject', organization_id: 200000001, user_id: 12 } })
While ELK supports a variety of attributes, note that not all of them are included in the current version of this formatter. Some examples of these attributes are:
"user.id", "user.login", "project.id", "project.identifier", "organization.id", "organization.domain", "client.ip"
"user_agent.original", "http.request.referrer", "url.original", "extra.attributes", "extra.backtrace"