Skip to content

Commit

Permalink
Added isEnabled() API method for checking logger enablement (#60)
Browse files Browse the repository at this point in the history
* Exported `isEnabled()` as API method

* Added documentation for `isEnabled()` API method
  • Loading branch information
klaudiosinani authored Sep 6, 2018
1 parent f275c40 commit 0f98521
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
22 changes: 22 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
10 changes: 5 additions & 5 deletions signale.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ class Signale {
});
}

get isEnabled() {
return !this._disabled;
}

get date() {
return new Date().toLocaleDateString();
}
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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.');
Expand Down

0 comments on commit 0f98521

Please sign in to comment.