Financial-Times/dotcom-reliability-kit

Make the logger configurable

Closed this issue · 0 comments

In the log-error and middleware-log-errors packages, we currently use n-logger to output logs. This should maybe be a configurable option, allowing a team to pass in their own compatible logger.

What problem does this feature solve?

In the @Financial-Times/acquisition Reliability Kit workshop, they requested that we make the logger configurable. This would allow them to use the Reliability Kit logger and logging middleware with n-mask-logger, which is a requirement for them.

Ideal solution

I think making this a config option for our logging packages would solve this. E.g:

const createErrorLogger = require('@dotcom-reliability-kit/middleware-log-errors');
const {logRecoverableError} = require('@dotcom-reliability-kit/log-error');
const MaskLogger = require('@financial-times/n-mask-logger');

app.use(createErrorLogger({
    logger: new MaskLogger(['email', 'password'])
}));

const errorWithPersonalData = new Error('Oops');
errorWithPersonalData.email = 'oops@ft.com';

logRecoverableError({
    error: errorWithPersonalData,
    logger: new MaskLogger(['email', 'password'])
});

Alternatives

  • We could do nothing, but that blocks Acquisition from using Reliability Kit in certain places.

See also

CPREL-327