Skip to content

Commit 7161d04

Browse files
committed
docs: add panic and colour configuration
1 parent c44455c commit 7161d04

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,25 @@ app:main Creating new user { email: '[email protected]' }
9797
> app:auth:warning User authentication failed { email: '[email protected]' }
9898
> ```
9999
100+
### Panic
101+
102+
Each logger instance includes a `panic` method that can be used for critical errors that should halt execution completely:
103+
104+
```ts
105+
const log = w("app:critical");
106+
log.panic("Fatal error occurred", { error }); // This will never return
107+
```
108+
109+
By default, panic will:
110+
111+
1. Log the error message to stderr
112+
2. Print a stack trace
113+
3. Trigger a debugger break
114+
4. Attempt to exit the process or show an alert (in browsers)
115+
5. Fallback to infinite loop
116+
117+
You can configure panic to throw an error instead by setting the `W_PANIC_THROWS=1` environment variable.
118+
100119
### Programmatic Control
101120
102121
An individual logger instance can also be enabled or disabled programmatically:
@@ -120,6 +139,14 @@ log.logger = console.log.bind(console); // or
120139
log.logger = (...args) => console.log("[CUSTOM]", ...args);
121140
```
122141
142+
### Colour Configuration
143+
144+
By default, `w`iretap will use colours in environments that support it. `w`iretap will read the following environment variables (in order of precedence):
145+
146+
- `FORCE_COLOR`: Force enable coloured output
147+
- `NO_COLOR`: Disable coloured output
148+
- `CI`: Disable coloured output in CI environments
149+
123150
## Supported Environments:
124151
125152
- Node.js

0 commit comments

Comments
 (0)