@rawnodes/logger 1.4.0 → 1.5.0
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 +29 -7
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@ Flexible Winston-based logger with AsyncLocalStorage context, level overrides, a
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Context Propagation** - Automatic context via AsyncLocalStorage
|
|
8
|
-
- **Level Overrides** - Debug specific users/
|
|
8
|
+
- **Level Overrides** - Debug specific users/modules without global log level change
|
|
9
|
+
- **Lazy Meta** - Defer metadata creation until log level check passes
|
|
9
10
|
- **Timing Utilities** - Built-in performance measurement
|
|
10
11
|
- **Request ID** - Generate and extract request IDs
|
|
11
12
|
- **Secret Masking** - Mask sensitive data in logs
|
|
@@ -103,22 +104,43 @@ interface LoggerConfig {
|
|
|
103
104
|
|
|
104
105
|
## Level Overrides
|
|
105
106
|
|
|
106
|
-
Debug specific users without changing global log level:
|
|
107
|
+
Debug specific users/modules without changing global log level:
|
|
107
108
|
|
|
108
109
|
```typescript
|
|
109
110
|
// Enable debug logging for user 123
|
|
110
|
-
|
|
111
|
+
logger.setLevelOverride({ userId: 123 }, 'debug');
|
|
111
112
|
|
|
112
|
-
//
|
|
113
|
-
|
|
113
|
+
// Enable debug only for 'auth' module
|
|
114
|
+
const authLogger = logger.child('auth');
|
|
115
|
+
logger.setLevelOverride({ context: 'auth' }, 'debug');
|
|
116
|
+
|
|
117
|
+
// Enable debug for specific user in specific module
|
|
118
|
+
logger.setLevelOverride({ context: 'auth', userId: 123 }, 'debug');
|
|
119
|
+
|
|
120
|
+
// Now only auth module logs for user 123 will include debug level
|
|
121
|
+
// Other users and modules still get the default level
|
|
114
122
|
|
|
115
123
|
// Remove override when done
|
|
116
|
-
|
|
124
|
+
logger.removeLevelOverride({ context: 'auth', userId: 123 });
|
|
117
125
|
|
|
118
126
|
// Or clear all overrides
|
|
119
|
-
|
|
127
|
+
logger.clearLevelOverrides();
|
|
120
128
|
```
|
|
121
129
|
|
|
130
|
+
## Lazy Meta
|
|
131
|
+
|
|
132
|
+
Avoid creating objects when log level doesn't allow logging:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// Object is always created (even if debug is disabled)
|
|
136
|
+
logger.debug('message', { heavy: computeExpensiveData() });
|
|
137
|
+
|
|
138
|
+
// Function is only called when debug level is enabled
|
|
139
|
+
logger.debug('message', () => ({ heavy: computeExpensiveData() }));
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This is useful for performance-critical code where you want debug logs but don't want to pay the cost of creating log metadata when debug is disabled.
|
|
143
|
+
|
|
122
144
|
## Timing
|
|
123
145
|
|
|
124
146
|
Measure execution time:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rawnodes/logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Flexible Winston-based logger with AsyncLocalStorage context, level overrides, and timing utilities",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -55,7 +55,11 @@
|
|
|
55
55
|
"winston-daily-rotate-file": "^5.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
59
|
+
"@semantic-release/git": "^10.0.1",
|
|
60
|
+
"@semantic-release/npm": "^13.1.3",
|
|
58
61
|
"@types/node": "^22.0.0",
|
|
62
|
+
"semantic-release": "^25.0.2",
|
|
59
63
|
"tsup": "^8.0.0",
|
|
60
64
|
"typescript": "^5.7.0",
|
|
61
65
|
"vitest": "^2.0.0"
|