From 2747cff88eea033694a4e2a45b355f1b221955f3 Mon Sep 17 00:00:00 2001 From: Guillaume Wuip Date: Mon, 2 Feb 2015 18:13:32 +0100 Subject: [PATCH] Allow custom time --- lib/console2.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/console2.js b/lib/console2.js index bf08ddf..65327ce 100644 --- a/lib/console2.js +++ b/lib/console2.js @@ -269,7 +269,7 @@ * * Log time (full date) ? * - * @type {Boolean} + * @type {Boolean|Number|String} */ this._time = false; @@ -325,9 +325,11 @@ * Console2.prototype.time * * Log the time + * + * @param {String|Number} time Optional time if need to override. */ - Console2.prototype.time = function () { - this._time = true; + Console2.prototype.time = function (time) { + this._time = time || true; return this; }; @@ -585,7 +587,7 @@ //or build the location var location = (this._location || this.opt.alwaysLocation) === true ? getLocation() : this._location; - var time = Date.now(); + var time = (typeof this._time !== 'boolean') ? this._time : Date.now(); // Let's build the log object @@ -594,7 +596,7 @@ show : { tags : this._tags.length > 0 || this.opt.alwaysTags || opt.defaultTags.length > 0, location : this._location !== false || this.opt.alwaysLocation, - time : this._time || this.opt.alwaysTime, + time : this._time !== false || this.opt.alwaysTime, date : this._date || this.opt.alwaysDate }, context : {