@crowdin/logs-formatter
TypeScript icon, indicating that this package has built-in type declarations

2.1.8 • Public • Published

Crowdin Logs Formatter

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:

coverage report

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());

List of console methods to be modified

console.log();
console.debug();
console.info();
console.warn();
console.trace();
console.error();
console.fatal();

Use the setContext method to set parameters for user identification. Here's an example

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"

Readme

Keywords

none

Package Sidebar

Install

npm i @crowdin/logs-formatter

Weekly Downloads

96

Version

2.1.8

License

ISC

Unpacked Size

28.7 kB

Total Files

11

Last publish

Collaborators

  • taras.prosvirov
  • serhiydmytryshyn
  • andrii.bodnar