forked from mirrors/Scribe.js
Add default tags
This commit is contained in:
parent
4335f713b6
commit
2849d7ca0e
1 changed files with 15 additions and 3 deletions
|
@ -218,6 +218,9 @@
|
|||
* @param {Boolean} opt.alwaysLocation Always print location (even without file() ). Default false.
|
||||
* @param {Boolean} opt.alwaysTime Always print time (even without time() ). Default false.
|
||||
* @param {Boolean} opt.alwaysDate Always print date (even without date() ). Default false.
|
||||
*
|
||||
* @param {Array} opt.defaultTags Default tags to logs with each request. Default [].
|
||||
* See this.tag()
|
||||
*/
|
||||
var Console2 = function (opt) {
|
||||
|
||||
|
@ -247,7 +250,9 @@
|
|||
alwaysTags : opt.alwaysTags === true,
|
||||
alwaysLocation : opt.alwaysLocation === true,
|
||||
alwaysTime : opt.alwaysTime === true,
|
||||
alwaysDate : opt.alwaysDate === true
|
||||
alwaysDate : opt.alwaysDate === true,
|
||||
|
||||
defaultTags : opt.defaultTags || []
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -522,6 +527,9 @@
|
|||
* @param {Boolean} opt.alwaysLocation Always print location (even without file() )
|
||||
* @param {Boolean} opt.alwaysTime Always print time (even without time() )
|
||||
* @param {Boolean} opt.alwaysDate Always print date (even without date() )
|
||||
*
|
||||
* @param {Array} opt.defaultTags Default tags to logs with each request. Default undefined.
|
||||
* See this.tag()
|
||||
*/
|
||||
Console2.prototype.addLogger = function (name, colors, opt) {
|
||||
|
||||
|
@ -549,6 +557,10 @@
|
|||
opt.alwaysTime = opt.alwaysTime || this.opt.alwaysTime;
|
||||
opt.alwaysDate = opt.alwaysDate || this.opt.alwaysDate;
|
||||
|
||||
opt.defaultTags = Array.isArray(opt.defaultTags) ?
|
||||
opt.defaultTags.concat(this.opt.defaultTags)
|
||||
: this.opt.defaultTags;
|
||||
|
||||
/**
|
||||
* this.[name]
|
||||
*
|
||||
|
@ -565,13 +577,13 @@
|
|||
var log = {
|
||||
type : opt.type || name,
|
||||
show : {
|
||||
tags : this._tags.length > 0 || this.opt.alwaysTags,
|
||||
tags : this._tags.length > 0 || this.opt.alwaysTags || opt.defaultTags.length > 0,
|
||||
location : this._location || this.opt.alwaysLocation,
|
||||
time : this._time || this.opt.alwaysTime,
|
||||
date : this._date || this.opt.alwaysDate
|
||||
},
|
||||
context : {
|
||||
tags : this._tags,
|
||||
tags : opt.defaultTags.concat(this._tags),
|
||||
file : this._location,
|
||||
time : time,
|
||||
location : location
|
||||
|
|
Loading…
Add table
Reference in a new issue