util: add inspectTag template literal tag
Introduces a simple template literal tag that ensures that each constituent part of the template literal passes through util.inspect()
using the default options.
This is inspired by recent changes in tests that have tried to convert console.log('message', a, b)
to something like:
`message ${a} ${b}`
const inspectTag = require('util').inspectTag;
const m = {a: 1};
console.log(`${m}`);
// Prints: '[object Object]'
console.log(inspectTag`${m}`);
// Prints: '{ a : 1 }'
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
Affected core subsystem(s)
util