Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-roemer committed Mar 1, 2015
1 parent fe2e587 commit b88e925
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ var con = new window.SimpleConsole();
con.log("Hello world!");
```

### Noop Logger

There are some cases where you will want to conditionally silence the logger.
You can do this by passing `null` as the `target` parameter to the logger like:

```js
var con = new SimpleConsole(null); // `{}` also works.
con.log("Hello world!"); // => Should _not_ output anything.
```

This is usually useful in a case where you build different capabilities based
on some external information, for example, React-style, this could be
something like:

```js
var con = "production" !== process.env.NODE_ENV ?
new SimpleConsole() : // Actual, working logger.
new SimpleConsole(null); // Noop (sinkhole) logger.

con.log("Hello world!"); // => Should _not_ output anything in `production`.
```

### Polyfill

If you are looking to **polyfill** `console`, then you can:
Expand Down

0 comments on commit b88e925

Please sign in to comment.