Skip to content

Instantly share code, notes, and snippets.

@chris-peng-1244
Last active July 27, 2018 07:53
Show Gist options
  • Select an option

  • Save chris-peng-1244/0cc5976437ad3dad6c727ac0f106e84d to your computer and use it in GitHub Desktop.

Select an option

Save chris-peng-1244/0cc5976437ad3dad6c727ac0f106e84d to your computer and use it in GitHub Desktop.
Winston@3.0 customize timestamp
module.exports = format((info, opts) => {
if (opts.format) {
info.timestamp = typeof opts.format === 'function'
? opts.format()
: fecha.format(new Date(), opts.format);
}
if (!info.timestamp) {
info.timestamp = new Date().toISOString();
}
if (opts.alias) {
info[opts.alias] = info.timestamp;
}
return info;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment