mirror of
https://github.com/mathew-kurian/Scribe.js
synced 2025-04-24 22:34:58 +00:00
Merge pull request #17 from guillaumewuip/feature-chainingLoggers
Feature chaining loggers
This commit is contained in:
commit
c51b9d3fc9
3 changed files with 21 additions and 0 deletions
10
README.md
10
README.md
|
@ -255,6 +255,9 @@ console.log(
|
||||||
"A String"
|
"A String"
|
||||||
);
|
);
|
||||||
console.tag("Combo!").time().file().log("A combo");
|
console.tag("Combo!").time().file().log("A combo");
|
||||||
|
|
||||||
|
//Chaining loggers
|
||||||
|
console.info('Some info').tag('A tag').log('Some logs').warning('Some warning');
|
||||||
```
|
```
|
||||||
|
|
||||||
**Params** : (all optional)
|
**Params** : (all optional)
|
||||||
|
@ -386,9 +389,14 @@ Do not use this unless you want to change how context (tags/location/time/date/.
|
||||||
|
|
||||||
###Console2.\[your logger](*args)
|
###Console2.\[your logger](*args)
|
||||||
|
|
||||||
|
|
||||||
Will print `*args` to the console, with context if there is.
|
Will print `*args` to the console, with context if there is.
|
||||||
See `Console2.buildArgs()`.
|
See `Console2.buildArgs()`.
|
||||||
|
|
||||||
|
**Params** : anything, printf format, etc.
|
||||||
|
|
||||||
|
**Return** : the Console2 instance.
|
||||||
|
|
||||||
**Example** :
|
**Example** :
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -402,6 +410,8 @@ console.tag('Multiple args and big context').time().file().demo(
|
||||||
[1, 2], //array
|
[1, 2], //array
|
||||||
{ foo : 'bar' } //object
|
{ foo : 'bar' } //object
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("Demo").time().warning("Test").info("some info");
|
||||||
```
|
```
|
||||||
|
|
||||||
See [`/examples/console2.js`](/examples/console2.js)
|
See [`/examples/console2.js`](/examples/console2.js)
|
||||||
|
|
|
@ -35,3 +35,6 @@ console.log(
|
||||||
);
|
);
|
||||||
console.tag("Combo!").time().file().log("A combo");
|
console.tag("Combo!").time().file().log("A combo");
|
||||||
|
|
||||||
|
//Chaining loggers
|
||||||
|
console.info('Some info').tag('A tag').log('Some logs').warning('Some warning');
|
||||||
|
|
||||||
|
|
|
@ -519,6 +519,12 @@
|
||||||
opt.alwaysTime = opt.alwaysTime || this.opt.alwaysTime;
|
opt.alwaysTime = opt.alwaysTime || this.opt.alwaysTime;
|
||||||
opt.alwaysDate = opt.alwaysDate || this.opt.alwaysDate;
|
opt.alwaysDate = opt.alwaysDate || this.opt.alwaysDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this.[name]
|
||||||
|
*
|
||||||
|
* @params anything you want, printf formar, etc.
|
||||||
|
* @return {Console2} this
|
||||||
|
*/
|
||||||
this[name] = function () {
|
this[name] = function () {
|
||||||
|
|
||||||
var location = getLocation();
|
var location = getLocation();
|
||||||
|
@ -593,6 +599,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this._reset();
|
this._reset();
|
||||||
|
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.loggers[name] = opt;
|
this.loggers[name] = opt;
|
||||||
|
|
Loading…
Add table
Reference in a new issue