xpl / ololog

A better console.log for the log-driven debugging junkies
https://www.npmjs.com/package/ololog
The Unlicense
215 stars 8 forks source link

Please provide an option to print date in local value #5

Closed ourarash closed 6 years ago

ourarash commented 6 years ago

Currently when you set date:true, the date if printed in ISO format:

2018-04-27T18:30:09.573Z

It would be great to show it in local value

ourarash commented 6 years ago

I was able to do it this way:

const log = require("ololog").configure({ time: { yes: true, print: x => ( x.toLocaleString() + ' | ') }});

xpl commented 6 years ago

@ourarash Thank you for the suggestion. Here you go (see the updated docs):

https://github.com/xpl/ololog#timestamping

The locale format option is now enabled by default (instead of ISO). You can also change it this way:

log = log.configure ({ time: { yes: true, format: 'iso' } })

Here is the correspondence between the format option value and the related Date method used for rendering:

format value Date method
"locale" .toLocaleString ()
"iso" .toISOString ()
"utc" .toUTCString ()
null .toString ()
xpl commented 6 years ago

@ourarash Hmm, it looks like the Travis CI deploy script is somehow got broken, as these changes are not deployed to NPM. I'll figure out the problem soon.

xpl commented 6 years ago

@ourarash It is finally available in NPM, sorry for the delay.