Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isEnabled() API Method for Logger Enablement Check #60

Merged
merged 2 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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