@microphi/debug 2.2.0 → 2.2.1

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 +20 -5
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  > Super simple wrapper around console.log
4
4
 
5
+
5
6
  # Install
6
7
  ```
7
8
  @microphi/debug
8
9
  ```
9
10
 
10
- # Log
11
+ ## Use in nodejs
11
12
 
12
13
  ```javascript
13
14
  import { getDebugger } from "@microphi/debug";
@@ -20,9 +21,23 @@ setTimeout(() => {
20
21
  d('hello there');
21
22
  }, 500);
22
23
  ```
23
- You need to set the `DEBUG` environment variable if running on nodejs or `localStorage.debug` if running in the browser.
24
- In any case its value is a comma separated list of regex: if a match happens with the namespace then the text will be logged using `console.log`.
24
+ Set `DEBUG` environment variable with a comma separated list of regex: if a match happens with a namespace then the text will be logged using `console.log`.
25
+
26
+
27
+ ![nodejs example output](../../.github/assets/debug_nodejs_output.png)
28
+
29
+ ## Use in the browser
30
+ Set `localStorage.debug` with a comma separated list of regex: if a match happens with a namespace then the text will be logged using `console.log`.
25
31
 
26
- On each line a timestap is printed and if two or more line from the same namespace are printed out in less the one second then they will show `+ xxx ms` to indicate their offset.
32
+ ![browser example output](../../.github/assets/debug_browser_output.png)
27
33
 
28
- ![nodejs example output](https://github.com/microph1/microphi/raw/master/.github/assets/debug_nodejs_output.png)
34
+ In this case `localStorage.debug` is set to `musicbox:*`
35
+
36
+ ### OnMessage handler
37
+ With `OnMessage` is possible to handle each message logged regardless of the regexes provided. This may be usefull to send the logs to a server or to to store them to a file.
38
+
39
+ ```javascript
40
+ onMessage((message) => {
41
+ // do something
42
+ });
43
+ ```
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "files": [
17
17
  "lib"
18
18
  ],
19
- "version": "2.2.0",
19
+ "version": "2.2.1",
20
20
  "dependencies": {
21
21
  "tslib": "^2.5.0"
22
22
  },
@@ -27,5 +27,5 @@
27
27
  "prepack": "yarn build",
28
28
  "lint": "eslint ./src"
29
29
  },
30
- "gitHead": "f1120b91036014e2881c049713ebc00f7c965f4f"
30
+ "gitHead": "4c47fafd3298beccdf5a652716dd5f8991f3471b"
31
31
  }