Skip to content

Commit 830c3e4

Browse files
authored
Added note about unit tests.
1 parent c8d79b0 commit 830c3e4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Readme.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ const basicLogger = logging.getLogger('basic');
5959
const overriddenLogger = logging.getLogger('overridden', { streams: [ /* ... */ ] });
6060
```
6161

62+
#### Usage with Unit Tests
63+
64+
Generally, when you're running unit tests, you don't want most logging. The easiest way to achieve this is by setting the `LOG_LEVEL` environment variable to `'ERROR'`. You can do this at the top of your unit test:
65+
66+
```javascript
67+
// Set `LOG_LEVEL` before importing your code that imports `trivial-logging`
68+
process.env.LOG_LEVEL = 'ERROR';
69+
70+
const { expect } = require('chai');
71+
72+
// ... rest of unit test
73+
```
74+
75+
Make sure that you set `process.env.LOG_LEVEL` _before_ importing any code that imports `trivial-logging`.
76+
6277
## API
6378

6479
### `init(config)`

0 commit comments

Comments
 (0)