Package detail

@studio/log-x

x-out confidential data in log entries

log, filter, x-out, confidential

readme

Studio Log X

❎ X-out confidential data in log entries of a Studio Log stream.

Usage

const logger = require('@studio/log').out(process.stdout);
const logX = require('@studio/log-x');

const log = 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.

Install

❯ npm i @studio/log-x

API

  • x(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...): Like x(path...), but only for the specified namespace.
  • x.ns(ns, map): Like x(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');

Supported notations

  • 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.

Related modules

License

MIT

Made with ❤️ on 🌍

changelog

Changes

1.3.1

  • 🐛 828738c Fix handling of null and prototype-less objects

1.3.0

  • 🍏 2b6c278 Introduce all to combine the given x-out transforms

1.2.0

  • 🍏 493378a Add x.ns API to create a transform for the given namespace
  • 🐛 2abd3df Make eslint happy
  • b933b6d Use Referee
  • 📚 ee433ab Add commit links with --commits
  • 📚 d1070ac Add install instructions
  • 📚 db9a3b4 Update install instruction

1.1.0

  • 🍏 Support array index, quoted properties and wildcard properties.

    • items[0]: Array index access.
    • item[':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.

1.0.0

  • ✨ Initial release