forked from mirrors/Scribe.js
Allow user to force location
This commit is contained in:
parent
5c4e3b6c89
commit
3a02270c46
1 changed files with 20 additions and 5 deletions
|
@ -287,7 +287,7 @@
|
|||
*
|
||||
* Should we log filename and line number ?
|
||||
*
|
||||
* @type {Boolean}
|
||||
* @type {Boolean|Object}
|
||||
*/
|
||||
this._location = false;
|
||||
|
||||
|
@ -362,9 +362,21 @@
|
|||
* Console2.prototype.file
|
||||
*
|
||||
* Log the file name + line
|
||||
* You could force the filename and line by passing args.
|
||||
*
|
||||
* @param {String} file Filename. Optional
|
||||
* @param {String|Number} line Line. Optional
|
||||
*/
|
||||
Console2.prototype.file = Console2.prototype.f = function () {
|
||||
this._location = true;
|
||||
Console2.prototype.file = Console2.prototype.f = function (file, line) {
|
||||
|
||||
if (file || line) {
|
||||
this._location = {
|
||||
filename : file,
|
||||
line : line
|
||||
};
|
||||
} else {
|
||||
this._location = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -569,7 +581,10 @@
|
|||
*/
|
||||
this[name] = function () {
|
||||
|
||||
var location = getLocation();
|
||||
//use this._location if it's an object (custom location)
|
||||
//or build the location
|
||||
var location = (this._location || this.opt.alwaysLocation) === true ? getLocation() : this._location;
|
||||
|
||||
var time = Date.now();
|
||||
|
||||
// Let's build the log object
|
||||
|
@ -578,7 +593,7 @@
|
|||
type : opt.type || name,
|
||||
show : {
|
||||
tags : this._tags.length > 0 || this.opt.alwaysTags || opt.defaultTags.length > 0,
|
||||
location : this._location || this.opt.alwaysLocation,
|
||||
location : this._location !== false || this.opt.alwaysLocation,
|
||||
time : this._time || this.opt.alwaysTime,
|
||||
date : this._date || this.opt.alwaysDate
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue