diff --git a/readme.md b/readme.md index 0a415bfd..e98cd4a4 100644 --- a/readme.md +++ b/readme.md @@ -749,6 +749,28 @@ signale.success('foo'); //=> ✔ success foo ``` +#### signale.`isEnabled()` + +Checks whether the logging functionality of a specific instance is enabled. + +```js +const signale = require('signale'); + +signale.success('foo'); +//=> ✔ success foo + +signale.isEnabled(); +// => true + +signale.disable(); + +signale.success('foo'); +//=> + +signale.isEnabled(); +// => false +``` + ## Development For more info on how to contribute to the project, please read the [contributing guidelines](https://github.com/klauscfhq/signale/blob/master/contributing.md). diff --git a/signale.js b/signale.js index 5ad1070f..183ef2ea 100644 --- a/signale.js +++ b/signale.js @@ -47,10 +47,6 @@ class Signale { }); } - get isEnabled() { - return !this._disabled; - } - get date() { return new Date().toLocaleDateString(); } @@ -256,7 +252,7 @@ class Signale { } _log(message, streams = this._stream) { - if (this.isEnabled) { + if (this.isEnabled()) { this._formatStream(streams).forEach(stream => { this._write(stream, message); }); @@ -295,6 +291,10 @@ class Signale { this._disabled = false; } + isEnabled() { + return !this._disabled; + } + scope(...name) { if (name.length === 0) { throw new Error('No scope name was defined.');