-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
logger(docs): include an example setup with some configurations (#1899)
- Loading branch information
Showing
1 changed file
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,41 @@ mimics the default node `console` API with three additions: | |
- `setLevel(LogLevel)`: sets the `LogLevel` of the logger. | ||
- `setName(string)`: sets a prefix to display in logs. Useful if you have multiple loggers active. | ||
|
||
### Example | ||
|
||
This short snippet shows various `Logger` levels and customized labels: | ||
|
||
```javascript | ||
const { ConsoleLogger, LogLevel } = require("@slack/logger"); | ||
|
||
const logger = new ConsoleLogger(); | ||
|
||
logger.error("a problem happened"); | ||
logger.warn("might need attention"); | ||
logger.info("take note of this"); | ||
logger.debug("or dig into details"); | ||
|
||
logger.setName("HAL"); | ||
logger.setLevel(LogLevel.DEBUG); | ||
|
||
logger.info("what an observation"); | ||
logger.debug("i am so interested"); | ||
``` | ||
|
||
When run, messages that match the following values are logged: | ||
|
||
```txt | ||
[ERROR] a problem happened | ||
[WARN] might need attention | ||
[INFO] take note of this | ||
[INFO] HAL what an observation | ||
[DEBUG] HAL i am so interested | ||
``` | ||
|
||
## Getting Help | ||
|
||
If you get stuck, we're here to help. The following are the best ways to get assistance working through your issue: | ||
|
||
* [Issue Tracker](http://github.com/slackapi/node-slack-sdk/issues) for questions, feature requests, bug reports and | ||
general discussion related to this package. Try searching before you create a new issue. | ||
* [Email us](mailto:[email protected]) in Slack developer support: `[email protected]` | ||
- [Issue Tracker](http://github.com/slackapi/node-slack-sdk/issues) for questions, feature requests, bug reports and | ||
general discussion related to this package. Try searching before you create a new issue. | ||
- [Email us](mailto:[email protected]) in Slack developer support: `[email protected]` |