@mcesystems/tool-debug-g4 1.0.91 → 1.0.92
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.
- package/README.md +106 -106
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
# @mcesystems/tool-debug
|
|
2
|
-
|
|
3
|
-
Small logging helpers built on top of `debug`, with consistent namespaces and colors.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
pnpm add @mcesystems/tool-debug-g4
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick start
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
import {
|
|
15
|
-
logNamespace,
|
|
16
|
-
setLogLevel,
|
|
17
|
-
logInfo,
|
|
18
|
-
logTask,
|
|
19
|
-
logWarning,
|
|
20
|
-
logErrorObject,
|
|
21
|
-
} from "@mcesystems/tool-debug-g4";
|
|
22
|
-
|
|
23
|
-
logNamespace("usb-listener");
|
|
24
|
-
setLogLevel("info");
|
|
25
|
-
|
|
26
|
-
logInfo("Starting USB listener");
|
|
27
|
-
logTask("Scanning devices");
|
|
28
|
-
logWarning("Device response is slow");
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
// ... work
|
|
32
|
-
} catch (error) {
|
|
33
|
-
logErrorObject(error, "USB listener failed");
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Log levels
|
|
38
|
-
|
|
39
|
-
`setLogLevel` toggles which loggers are enabled:
|
|
40
|
-
|
|
41
|
-
- `info`: enables `info`, `task`, `error`, `warning`
|
|
42
|
-
- `debug`: enables all loggers
|
|
43
|
-
- `none`: disables all loggers
|
|
44
|
-
|
|
45
|
-
If you prefer the default `debug` behavior, you can skip `setLogLevel` and use the
|
|
46
|
-
`DEBUG` environment variable (for example `DEBUG=usb-listener:*`) to control output.
|
|
47
|
-
|
|
48
|
-
## Namespaces
|
|
49
|
-
|
|
50
|
-
`logNamespace("usb-listener")` sets all loggers to `usb-listener:<type>`, so your
|
|
51
|
-
`DEBUG` filter can target them consistently.
|
|
52
|
-
|
|
53
|
-
## Custom colors
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
import { setColors, printColors } from "@mcesystems/tool-debug-g4";
|
|
57
|
-
|
|
58
|
-
setColors("info", "33");
|
|
59
|
-
setColors("error", "196");
|
|
60
|
-
|
|
61
|
-
// Optional helper to preview 0-255 color codes
|
|
62
|
-
printColors();
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Helpers
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
import { logHeader, logDataObject, logErrorObject } from "@mcesystems/tool-debug-g4";
|
|
69
|
-
|
|
70
|
-
logHeader("USB session");
|
|
71
|
-
logDataObject("Detected devices", { count: 2, ids: ["abc", "def"] });
|
|
72
|
-
logErrorObject(new Error("Device not found"));
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Example output (format varies by terminal):
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
usb-listener:info ================================================================================
|
|
79
|
-
usb-listener:info USB session
|
|
80
|
-
usb-listener:info ================================================================================
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
usb-listener:detail ================================================================================
|
|
85
|
-
usb-listener:detail *Detected devices* <anonymous>
|
|
86
|
-
usb-listener:detail ================================================================================
|
|
87
|
-
usb-listener:detail
|
|
88
|
-
usb-listener:detail # count: 2
|
|
89
|
-
usb-listener:detail # ids:
|
|
90
|
-
usb-listener:detail # 0: abc
|
|
91
|
-
usb-listener:detail # 1: def
|
|
92
|
-
usb-listener:detail
|
|
93
|
-
usb-listener:detail ================================================================================
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
usb-listener:error ================================================================================
|
|
98
|
-
usb-listener:error Device not found
|
|
99
|
-
usb-listener:error ================================================================================
|
|
100
|
-
usb-listener:error Error Message:
|
|
101
|
-
usb-listener:error Device not found
|
|
102
|
-
usb-listener:error Error Stack:
|
|
103
|
-
usb-listener:error Error: Device not found
|
|
104
|
-
usb-listener:error at ...
|
|
105
|
-
usb-listener:error ================================================================================
|
|
106
|
-
```
|
|
1
|
+
# @mcesystems/tool-debug
|
|
2
|
+
|
|
3
|
+
Small logging helpers built on top of `debug`, with consistent namespaces and colors.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pnpm add @mcesystems/tool-debug-g4
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
import {
|
|
15
|
+
logNamespace,
|
|
16
|
+
setLogLevel,
|
|
17
|
+
logInfo,
|
|
18
|
+
logTask,
|
|
19
|
+
logWarning,
|
|
20
|
+
logErrorObject,
|
|
21
|
+
} from "@mcesystems/tool-debug-g4";
|
|
22
|
+
|
|
23
|
+
logNamespace("usb-listener");
|
|
24
|
+
setLogLevel("info");
|
|
25
|
+
|
|
26
|
+
logInfo("Starting USB listener");
|
|
27
|
+
logTask("Scanning devices");
|
|
28
|
+
logWarning("Device response is slow");
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
// ... work
|
|
32
|
+
} catch (error) {
|
|
33
|
+
logErrorObject(error, "USB listener failed");
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Log levels
|
|
38
|
+
|
|
39
|
+
`setLogLevel` toggles which loggers are enabled:
|
|
40
|
+
|
|
41
|
+
- `info`: enables `info`, `task`, `error`, `warning`
|
|
42
|
+
- `debug`: enables all loggers
|
|
43
|
+
- `none`: disables all loggers
|
|
44
|
+
|
|
45
|
+
If you prefer the default `debug` behavior, you can skip `setLogLevel` and use the
|
|
46
|
+
`DEBUG` environment variable (for example `DEBUG=usb-listener:*`) to control output.
|
|
47
|
+
|
|
48
|
+
## Namespaces
|
|
49
|
+
|
|
50
|
+
`logNamespace("usb-listener")` sets all loggers to `usb-listener:<type>`, so your
|
|
51
|
+
`DEBUG` filter can target them consistently.
|
|
52
|
+
|
|
53
|
+
## Custom colors
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
import { setColors, printColors } from "@mcesystems/tool-debug-g4";
|
|
57
|
+
|
|
58
|
+
setColors("info", "33");
|
|
59
|
+
setColors("error", "196");
|
|
60
|
+
|
|
61
|
+
// Optional helper to preview 0-255 color codes
|
|
62
|
+
printColors();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Helpers
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
import { logHeader, logDataObject, logErrorObject } from "@mcesystems/tool-debug-g4";
|
|
69
|
+
|
|
70
|
+
logHeader("USB session");
|
|
71
|
+
logDataObject("Detected devices", { count: 2, ids: ["abc", "def"] });
|
|
72
|
+
logErrorObject(new Error("Device not found"));
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Example output (format varies by terminal):
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
usb-listener:info ================================================================================
|
|
79
|
+
usb-listener:info USB session
|
|
80
|
+
usb-listener:info ================================================================================
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
usb-listener:detail ================================================================================
|
|
85
|
+
usb-listener:detail *Detected devices* <anonymous>
|
|
86
|
+
usb-listener:detail ================================================================================
|
|
87
|
+
usb-listener:detail
|
|
88
|
+
usb-listener:detail # count: 2
|
|
89
|
+
usb-listener:detail # ids:
|
|
90
|
+
usb-listener:detail # 0: abc
|
|
91
|
+
usb-listener:detail # 1: def
|
|
92
|
+
usb-listener:detail
|
|
93
|
+
usb-listener:detail ================================================================================
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
usb-listener:error ================================================================================
|
|
98
|
+
usb-listener:error Device not found
|
|
99
|
+
usb-listener:error ================================================================================
|
|
100
|
+
usb-listener:error Error Message:
|
|
101
|
+
usb-listener:error Device not found
|
|
102
|
+
usb-listener:error Error Stack:
|
|
103
|
+
usb-listener:error Error: Device not found
|
|
104
|
+
usb-listener:error at ...
|
|
105
|
+
usb-listener:error ================================================================================
|
|
106
|
+
```
|