Open riker09 opened 6 years ago
I'm looking into a related issue, may have some updates for you soon!
FYI -- level: 'info',
not 'info',
, that may be one issue...
This feels like a bug related to format ordering and SPLAT
. This is a work-around in the mean-time:
const { createLogger, format, transports } = require('../');
const mask = format((info) => {
if (info.password) {
info.password = '****';
}
return info;
});
const logger = createLogger({
level: 'info',
format: format.combine(
format.splat(),
mask(),
format.simple()
),
transports: [
new transports.Console(),
],
});
const obj = {
username: "foo",
password: "bar",
};
logger.info('logging', obj);
Environment
winston
versionwinston@2
winston@3
node -v
outputs: v8.12.0What is the problem?
A few lines of code tell more than a picture:
The resulting log entry still has the value of field
password
in plain text:What do you expect to happen instead?
The value of the password field should be masked with four asterisks:
Other information