A simple logger and optional decorator for console.log() and company.
npm install log-a-log
There are a number of operational modes, configured via the mode
parameter:
local
- renders a local, ISO-8601 timestampcoded
- renders a color-coded, UTC, ISO-8601 timestamppony
- renders a very colorful, UTC, ISO-8601 timestamputc
[default] - renders single-color, UTC, ISO-8601 UTC timestampunix
- renders a millisecond-granularity unix timestamp
Uses @buzuli/color
, so colors can be configured to your preference (https://www.npmjs.com/package/@buzuli/color#configuration).
const logalog = require('log-a-log')
logalog({mode: 'local', alias: 'my-script'})
const name = "world"
console.log(`Hello, ${name}!`)
console.error(`Oh noes, ${name}!`)
Sample Output:
[2015-10-30T21:52:05.520-06:00]my-script|INFO> Hello, world!
[2015-10-30T21:52:05.520-06:00]my-script|ERROR> Oh noes, world!