❎ X-out confidential data in log entries of a Studio Log stream.
constlogger=require('@studio/log').out(process.stdout);constlogX=require('@studio/log-x');constlog=logger('app');log.filter(logX('connection.password'));log.input('db',{connection: {login: 'admin',password: 'secret'}});The above produces this log output:
{"ts":1486630378584,"ns":"app","topic":"input","msg":"db","data":{
"connection":{"login":"admin","password":"·····"}}}Data objects are copied before modification to make it safe to pass object references as log data.
❯ npm i @studio/log-xx(path...): Returns a transform stream in object mode that filters the properties at the given paths.x(map): Maps topic names to filters. The special*topic is used if no matching topic filter was specified.x.ns(ns, path...): Likex(path...), but only for the specified namespace.x.ns(ns, map): Likex(map), but only for the specified namespace.x.all(transform...): Combine the given x-out transforms.
// x(map)logX({input: ['connection.user','connection.password'],'*': ['token']});// x.ns(ns, path...)logX.ns('Login','request.user','request.password');key: Property access.key.path: Property path access.items[0]: Array index access.items[':a']: Quoted property access.item.*: All values in object.items[*]: All entries in array.item.*.key: Property access in each value of object.items[*].key: Property access in each entry of array.
- 👻 Studio Log logs ndjson to an output stream
- 📦 Studio Changes is used to create the changelog for this module.
MIT
Made with ❤️ on 🌍