Fix proto tag()

This commit is contained in:
Guillaume Wuip 2014-10-25 17:13:44 +02:00
parent dfc1588fa7
commit c5d042149b

View file

@ -27,12 +27,12 @@
};
/**
* buildDay
* buildDate
*
* @param {timestamp} timestamp
* @return {String} timestamp to string
*/
var buildDay = function (timestamp) {
var buildDate = function (timestamp) {
return (new Date(timestamp)).toDateString() + " ";
};
@ -77,13 +77,13 @@
this._time = false;
/**
* _day
* _date
*
* Log day ?
* Log date ?
*
* @type {Boolean}
*/
this._day = false;
this._date = false;
/**
* _location
@ -106,8 +106,8 @@
*/
this._reset = function () {
this._tags = [];
this._time = true;
this._day = false;
this._time = false;
this._date = false;
this.location = false;
return this;
@ -134,12 +134,12 @@
};
/**
* Console2.prototype.day
* Console2.prototype.date
*
* Log the day
* Log the date
*/
Console2.prototype.day = function () {
this._day = true;
Console2.prototype.date = function () {
this._date = true;
return this;
};
@ -151,7 +151,8 @@
* @param {String} tag
*/
Console2.prototype.tag = Console2.prototype.t = function () {
this._tags.push(arguments);
var tags = Array.prototype.slice.call(arguments, 0);
this._tags = this._tags.concat(tags);
return this;
};
@ -192,7 +193,7 @@
* @param {Boolean} opt.tags Optional. Print Tags ? Default false.
* @param {Boolean} opt.location Optional. Print location ? Default false.
* @param {Boolean} opt.time Optional. Print time ? Default false.
* @param {Boolean} opt.day Optional. Print day ? Default false.
* @param {Boolean} opt.date Optional. Print date ? Default false.
* @return {String} The message to print usualy.
*/
Console2.prototype.buildMessage = function (log, opt) {
@ -204,7 +205,7 @@
opt.tags = opt.tags || false;
opt.location = opt.location || false;
opt.time = opt.time || false;
opt.day = opt.day || false;
opt.date = opt.date || false;
var result = "";
@ -212,8 +213,8 @@
result += buildTime(log.context.time);
}
if (opt.day && log.context.day) {
result += buildDay(log.context.time);
if (opt.date && log.context.time) {
result += buildDate(log.context.time);
}
if (opt.tags && log.context.tags) {
@ -284,9 +285,10 @@
//Build the string message
log.message = this.buildMessage(log, {
tags : this._tags.length > 0 || false,
location : this._location.filename || false,
time : this._time || false,
day : this._day || false
date : this._date || false
});
//Emit events