Skip to content

Commit 283578a

Browse files
🚀 release: promote dev to main
1 parent 506b1d4 commit 283578a

20 files changed

Lines changed: 1844 additions & 12 deletions

.devcontainer/devcontainer.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/api-reference/enums.mdx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Enums
3+
description: LogMode and LogLevel enum reference
4+
icon: list-ol
5+
---
6+
7+
## LogMode
8+
9+
Controls output behavior and filtering. Determines what messages are displayed based on verbosity requirements.
10+
11+
```typescript
12+
import { LogMode } from '@wgtechlabs/log-engine';
13+
```
14+
15+
| Member | Value | Description |
16+
|--------|-------|-------------|
17+
| `LogMode.DEBUG` | `0` | Most verbose — shows DEBUG, INFO, WARN, ERROR, LOG |
18+
| `LogMode.INFO` | `1` | Balanced — shows INFO, WARN, ERROR, LOG |
19+
| `LogMode.WARN` | `2` | Focused — shows WARN, ERROR, LOG |
20+
| `LogMode.ERROR` | `3` | Minimal — shows ERROR, LOG |
21+
| `LogMode.SILENT` | `4` | Critical only — shows LOG only |
22+
| `LogMode.OFF` | `5` | Complete silence — shows nothing |
23+
24+
### Usage
25+
26+
```typescript
27+
// Recommended configuration approach
28+
LogEngine.configure({ mode: LogMode.DEBUG });
29+
LogEngine.configure({ mode: LogMode.INFO });
30+
LogEngine.configure({ mode: LogMode.WARN });
31+
LogEngine.configure({ mode: LogMode.ERROR });
32+
LogEngine.configure({ mode: LogMode.SILENT });
33+
LogEngine.configure({ mode: LogMode.OFF });
34+
```
35+
36+
### Visibility Matrix
37+
38+
| Method | DEBUG | INFO | WARN | ERROR | SILENT | OFF |
39+
|--------|:-----:|:----:|:----:|:-----:|:------:|:---:|
40+
| `debug()` | Yes ||||||
41+
| `info()` | Yes | Yes |||||
42+
| `warn()` | Yes | Yes | Yes ||||
43+
| `error()` | Yes | Yes | Yes | Yes |||
44+
| `log()` | Yes | Yes | Yes | Yes | Yes ||
45+
46+
---
47+
48+
## LogLevel
49+
50+
<Warning>
51+
`LogLevel` is **deprecated** for configuration purposes. Use `LogMode` instead. `LogLevel` will be removed in v3.0.0. See the [Migration Guide](/guides/migration).
52+
</Warning>
53+
54+
Represents message severity — how important a single log message is.
55+
56+
```typescript
57+
import { LogLevel } from '@wgtechlabs/log-engine';
58+
```
59+
60+
| Member | Value | Description |
61+
|--------|-------|-------------|
62+
| `LogLevel.DEBUG` | `0` | Detailed diagnostic information |
63+
| `LogLevel.INFO` | `1` | General information about application flow |
64+
| `LogLevel.WARN` | `2` | Potentially harmful situations |
65+
| `LogLevel.ERROR` | `3` | Error events |
66+
| `LogLevel.LOG` | `99` | Critical messages that always output (except OFF) |
67+
68+
### Legacy Usage (Deprecated)
69+
70+
```typescript
71+
// Deprecated - shows warning in console
72+
LogEngine.configure({ level: LogLevel.DEBUG });
73+
74+
// Recommended replacement
75+
LogEngine.configure({ mode: LogMode.DEBUG });
76+
```

docs/api-reference/log-engine.mdx

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
---
2+
title: LogEngine
3+
description: Complete API reference for the LogEngine singleton
4+
icon: code
5+
---
6+
7+
The `LogEngine` object is the main interface for all logging operations. It's a singleton that provides a simple, intuitive API with security-first design.
8+
9+
```typescript
10+
import { LogEngine } from '@wgtechlabs/log-engine';
11+
```
12+
13+
## Configuration
14+
15+
### configure
16+
17+
Configure the logger with new settings.
18+
19+
```typescript
20+
LogEngine.configure(config: Partial<LoggerConfig>): void
21+
```
22+
23+
<ParamField body="config" type="Partial<LoggerConfig>" required>
24+
Configuration object. See [LoggerConfig](/api-reference/types#loggerconfig) for all options.
25+
</ParamField>
26+
27+
```typescript
28+
LogEngine.configure({
29+
mode: LogMode.DEBUG,
30+
format: {
31+
includeIsoTimestamp: true,
32+
includeLocalTime: true,
33+
includeEmoji: true
34+
}
35+
});
36+
```
37+
38+
---
39+
40+
## Logging Methods
41+
42+
All standard logging methods accept the same parameters:
43+
44+
<ParamField body="message" type="string" required>
45+
The log message to display.
46+
</ParamField>
47+
48+
<ParamField body="data" type="LogData">
49+
Optional data object to log. Sensitive fields are automatically redacted.
50+
</ParamField>
51+
52+
<ParamField body="options" type="LogCallOptions">
53+
Optional per-call options (e.g., emoji override).
54+
</ParamField>
55+
56+
### debug
57+
58+
Log a debug message. Only shown in DEBUG mode.
59+
60+
```typescript
61+
LogEngine.debug(message: string, data?: LogData, options?: LogCallOptions): void
62+
```
63+
64+
### info
65+
66+
Log an info message. Shown in DEBUG and INFO modes.
67+
68+
```typescript
69+
LogEngine.info(message: string, data?: LogData, options?: LogCallOptions): void
70+
```
71+
72+
### warn
73+
74+
Log a warning message. Shown in DEBUG, INFO, and WARN modes.
75+
76+
```typescript
77+
LogEngine.warn(message: string, data?: LogData, options?: LogCallOptions): void
78+
```
79+
80+
### error
81+
82+
Log an error message. Shown in DEBUG, INFO, WARN, and ERROR modes.
83+
84+
```typescript
85+
LogEngine.error(message: string, data?: LogData, options?: LogCallOptions): void
86+
```
87+
88+
### log
89+
90+
Log a critical message. Always shown regardless of mode (except OFF).
91+
92+
```typescript
93+
LogEngine.log(message: string, data?: LogData, options?: LogCallOptions): void
94+
```
95+
96+
---
97+
98+
## Raw Logging Methods
99+
100+
<Warning>
101+
Raw methods bypass all data redaction. Use with caution.
102+
</Warning>
103+
104+
### debugRaw / infoRaw / warnRaw / errorRaw / logRaw
105+
106+
Same signature as standard methods, but without automatic redaction:
107+
108+
```typescript
109+
LogEngine.debugRaw(message: string, data?: LogData, options?: LogCallOptions): void
110+
LogEngine.infoRaw(message: string, data?: LogData, options?: LogCallOptions): void
111+
LogEngine.warnRaw(message: string, data?: LogData, options?: LogCallOptions): void
112+
LogEngine.errorRaw(message: string, data?: LogData, options?: LogCallOptions): void
113+
LogEngine.logRaw(message: string, data?: LogData, options?: LogCallOptions): void
114+
```
115+
116+
### withoutRedaction
117+
118+
Returns a LogEngine instance with redaction bypassed.
119+
120+
```typescript
121+
LogEngine.withoutRedaction(): ILogEngineWithoutRedaction
122+
```
123+
124+
```typescript
125+
LogEngine.withoutRedaction().info('Debug data', sensitiveObject);
126+
```
127+
128+
---
129+
130+
## Redaction Configuration
131+
132+
### configureRedaction
133+
134+
Configure data redaction settings.
135+
136+
```typescript
137+
LogEngine.configureRedaction(config: Partial<RedactionConfig>): void
138+
```
139+
140+
```typescript
141+
LogEngine.configureRedaction({
142+
redactionText: '***HIDDEN***',
143+
maxContentLength: 200,
144+
sensitiveFields: ['myCustomField', 'internalSecret']
145+
});
146+
```
147+
148+
### getRedactionConfig
149+
150+
Get the current redaction configuration.
151+
152+
```typescript
153+
LogEngine.getRedactionConfig(): RedactionConfig
154+
```
155+
156+
### refreshRedactionConfig
157+
158+
Refresh redaction configuration from environment variables.
159+
160+
```typescript
161+
LogEngine.refreshRedactionConfig(): void
162+
```
163+
164+
### resetRedactionConfig
165+
166+
Reset redaction configuration to defaults.
167+
168+
```typescript
169+
LogEngine.resetRedactionConfig(): void
170+
```
171+
172+
### addCustomRedactionPatterns
173+
174+
Add custom regex patterns for advanced field detection.
175+
176+
```typescript
177+
LogEngine.addCustomRedactionPatterns(patterns: RegExp[]): void
178+
```
179+
180+
```typescript
181+
LogEngine.addCustomRedactionPatterns([/internal.*/i, /company.*/i]);
182+
```
183+
184+
### clearCustomRedactionPatterns
185+
186+
Clear all custom redaction patterns.
187+
188+
```typescript
189+
LogEngine.clearCustomRedactionPatterns(): void
190+
```
191+
192+
### addSensitiveFields
193+
194+
Add custom sensitive field names to the existing list.
195+
196+
```typescript
197+
LogEngine.addSensitiveFields(fields: string[]): void
198+
```
199+
200+
```typescript
201+
LogEngine.addSensitiveFields(['companySecret', 'internalToken']);
202+
```
203+
204+
### testFieldRedaction
205+
206+
Test if a field name would be redacted with the current configuration.
207+
208+
```typescript
209+
LogEngine.testFieldRedaction(fieldName: string): boolean
210+
```
211+
212+
```typescript
213+
LogEngine.testFieldRedaction('password'); // true
214+
LogEngine.testFieldRedaction('username'); // false
215+
```

0 commit comments

Comments
 (0)