@leaflink/snitch 0.0.0-PR-17--33740bb → 0.0.0-PR-19--8055eb7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +38 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,6 +5,27 @@
5
5
 
6
6
  Simple and extensible browser logging, inspired by [Winston](https://github.com/winstonjs/winston).
7
7
 
8
+
9
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
10
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
11
+ ## Table of Contents
12
+
13
+ - [Installation](#installation)
14
+ - [Transports](#transports)
15
+ - [Log Levels](#log-levels)
16
+ - [Usage](#usage)
17
+ - [Singleton Logger](#singleton-logger)
18
+ - [New Logger](#new-logger)
19
+ - [Console Transport](#console-transport)
20
+ - [Sentry Transport](#sentry-transport)
21
+ - [Datadog Logs Transport](#datadog-logs-transport)
22
+ - [With Log Level](#with-log-level)
23
+ - [Custom Transports](#custom-transports)
24
+ - [Testing](#testing)
25
+ - [Stubbing snitch](#stubbing-snitch)
26
+
27
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
28
+
8
29
  ## Installation
9
30
 
10
31
  `$ npm i @leaflink/snitch`
@@ -215,3 +236,20 @@ logger.add(new CustomTransport());
215
236
  ```
216
237
 
217
238
  Note: You can add a custom transport in your project, but consider opening a PR in this repo instead!
239
+
240
+ ## Testing
241
+
242
+ ### Stubbing snitch
243
+
244
+ When there's a need to mock this logger or you want to test if a specific log was printed, you can just mock it inside you test file:
245
+
246
+ ```ts
247
+ import logger from '@leaflink/snitch';
248
+
249
+ vi.mock('@leaflink/snitch');
250
+
251
+ it('should redirect to error page if fetching the user profile fails', async () => {
252
+ // ...
253
+ expect(logger.error).toHaveBeenCalled();
254
+ })
255
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflink/snitch",
3
- "version": "0.0.0-PR-17--33740bb",
3
+ "version": "0.0.0-PR-19--8055eb7",
4
4
  "description": "Front end logging inspired by winston.",
5
5
  "type": "module",
6
6
  "exports": {