forked from mirrors/Scribe.js
Fix proto tag()
This commit is contained in:
parent
dfc1588fa7
commit
c5d042149b
1 changed files with 19 additions and 17 deletions
|
@ -27,12 +27,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* buildDay
|
* buildDate
|
||||||
*
|
*
|
||||||
* @param {timestamp} timestamp
|
* @param {timestamp} timestamp
|
||||||
* @return {String} timestamp to string
|
* @return {String} timestamp to string
|
||||||
*/
|
*/
|
||||||
var buildDay = function (timestamp) {
|
var buildDate = function (timestamp) {
|
||||||
return (new Date(timestamp)).toDateString() + " ";
|
return (new Date(timestamp)).toDateString() + " ";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@
|
||||||
this._time = false;
|
this._time = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _day
|
* _date
|
||||||
*
|
*
|
||||||
* Log day ?
|
* Log date ?
|
||||||
*
|
*
|
||||||
* @type {Boolean}
|
* @type {Boolean}
|
||||||
*/
|
*/
|
||||||
this._day = false;
|
this._date = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _location
|
* _location
|
||||||
|
@ -106,8 +106,8 @@
|
||||||
*/
|
*/
|
||||||
this._reset = function () {
|
this._reset = function () {
|
||||||
this._tags = [];
|
this._tags = [];
|
||||||
this._time = true;
|
this._time = false;
|
||||||
this._day = false;
|
this._date = false;
|
||||||
this.location = false;
|
this.location = false;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -134,12 +134,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Console2.prototype.day
|
* Console2.prototype.date
|
||||||
*
|
*
|
||||||
* Log the day
|
* Log the date
|
||||||
*/
|
*/
|
||||||
Console2.prototype.day = function () {
|
Console2.prototype.date = function () {
|
||||||
this._day = true;
|
this._date = true;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
@ -151,7 +151,8 @@
|
||||||
* @param {String} tag
|
* @param {String} tag
|
||||||
*/
|
*/
|
||||||
Console2.prototype.tag = Console2.prototype.t = function () {
|
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;
|
return this;
|
||||||
};
|
};
|
||||||
|
@ -192,7 +193,7 @@
|
||||||
* @param {Boolean} opt.tags Optional. Print Tags ? Default false.
|
* @param {Boolean} opt.tags Optional. Print Tags ? Default false.
|
||||||
* @param {Boolean} opt.location Optional. Print location ? Default false.
|
* @param {Boolean} opt.location Optional. Print location ? Default false.
|
||||||
* @param {Boolean} opt.time Optional. Print time ? 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.
|
* @return {String} The message to print usualy.
|
||||||
*/
|
*/
|
||||||
Console2.prototype.buildMessage = function (log, opt) {
|
Console2.prototype.buildMessage = function (log, opt) {
|
||||||
|
@ -204,7 +205,7 @@
|
||||||
opt.tags = opt.tags || false;
|
opt.tags = opt.tags || false;
|
||||||
opt.location = opt.location || false;
|
opt.location = opt.location || false;
|
||||||
opt.time = opt.time || false;
|
opt.time = opt.time || false;
|
||||||
opt.day = opt.day || false;
|
opt.date = opt.date || false;
|
||||||
|
|
||||||
var result = "";
|
var result = "";
|
||||||
|
|
||||||
|
@ -212,8 +213,8 @@
|
||||||
result += buildTime(log.context.time);
|
result += buildTime(log.context.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.day && log.context.day) {
|
if (opt.date && log.context.time) {
|
||||||
result += buildDay(log.context.time);
|
result += buildDate(log.context.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.tags && log.context.tags) {
|
if (opt.tags && log.context.tags) {
|
||||||
|
@ -284,9 +285,10 @@
|
||||||
|
|
||||||
//Build the string message
|
//Build the string message
|
||||||
log.message = this.buildMessage(log, {
|
log.message = this.buildMessage(log, {
|
||||||
|
tags : this._tags.length > 0 || false,
|
||||||
location : this._location.filename || false,
|
location : this._location.filename || false,
|
||||||
time : this._time || false,
|
time : this._time || false,
|
||||||
day : this._day || false
|
date : this._date || false
|
||||||
});
|
});
|
||||||
|
|
||||||
//Emit events
|
//Emit events
|
||||||
|
|
Loading…
Add table
Reference in a new issue