npm install giovannicalo/node-log
Not yet published to NPM. This will install it from GitHub.
const log = require("log");
log.info`Foo ${42}`;
// [2020-08-18T04:53:01.777Z] [INFO ] Foo 42
log.warning`Bar ${{ foo: "bar" }}`;
// [2020-08-18T04:53:01.781Z] [WARNING] Bar { foo: 'bar' }
log.error`Foo bar ${new Error("Something went wrong")}`;
// [2020-08-18T04:57:18.066Z] [ERROR ] Foo bar Error: Something went wrong
// Object.<anonymous>
// foo.js:5:21
// log.error`Foo bar ${new Error("Something went wrong")}`;
// ^
Prints the given message, interpolating strings
and enhanced values
, in addition to the current UTC timestamp and log level.
- Currently only works with CommonJS modules. It can't be used with ECMAScript modules.