Skip to content

Commit e5a4f3f

Browse files
authored
logger(docs): include an example setup with some configurations (#1899)
1 parent f37115b commit e5a4f3f

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

packages/logger/README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,41 @@ mimics the default node `console` API with three additions:
2626
- `setLevel(LogLevel)`: sets the `LogLevel` of the logger.
2727
- `setName(string)`: sets a prefix to display in logs. Useful if you have multiple loggers active.
2828

29+
### Example
30+
31+
This short snippet shows various `Logger` levels and customized labels:
32+
33+
```javascript
34+
const { ConsoleLogger, LogLevel } = require("@slack/logger");
35+
36+
const logger = new ConsoleLogger();
37+
38+
logger.error("a problem happened");
39+
logger.warn("might need attention");
40+
logger.info("take note of this");
41+
logger.debug("or dig into details");
42+
43+
logger.setName("HAL");
44+
logger.setLevel(LogLevel.DEBUG);
45+
46+
logger.info("what an observation");
47+
logger.debug("i am so interested");
48+
```
49+
50+
When run, messages that match the following values are logged:
51+
52+
```txt
53+
[ERROR] a problem happened
54+
[WARN] might need attention
55+
[INFO] take note of this
56+
[INFO] HAL what an observation
57+
[DEBUG] HAL i am so interested
58+
```
59+
2960
## Getting Help
3061

3162
If you get stuck, we're here to help. The following are the best ways to get assistance working through your issue:
3263

33-
* [Issue Tracker](http://github.com/slackapi/node-slack-sdk/issues) for questions, feature requests, bug reports and
34-
general discussion related to this package. Try searching before you create a new issue.
35-
* [Email us](mailto:[email protected]) in Slack developer support: `[email protected]`
64+
- [Issue Tracker](http://github.com/slackapi/node-slack-sdk/issues) for questions, feature requests, bug reports and
65+
general discussion related to this package. Try searching before you create a new issue.
66+
- [Email us](mailto:[email protected]) in Slack developer support: `[email protected]`

0 commit comments

Comments
 (0)