UNPKG

timed-log

Version:

A small revamp of console.log and console.error, adding time banners before messages

39 lines (34 loc) 736 B
/** * Timed Logging * Initially, just adds a formatted DateTime banner to * console.log (stdout) and console.error (stderr) * * @todo Make it more configurable */ 'use strict'; // Requirements var util = require('util') , moment = require('moment'); /** * Return a timestamp banner to be used with * @return {[type]} [description] */ function addTimeBanner(args) { var msg = [ util.format('>>> [%s]', moment().utc()), util.format.apply(null, args) ]; return msg; } /** * Log a non-error message */ exports.message = function () { console.log.apply(null, addTimeBanner(arguments)); }; /** * Log a error message */ exports.error = function () { console.error.apply(null, addTimeBanner(arguments)); };