logixia 1.5.0 → 1.6.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 +76 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/{index-Ium497V3.d.mts → index-C0sp2BVU.d.ts} +2 -2
- package/dist/index-C0sp2BVU.d.ts.map +1 -0
- package/dist/{index-t-ActikQ.d.ts → index-CNSfc_Or.d.mts} +2 -2
- package/dist/index-CNSfc_Or.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{logitron-logger.module-B7CsnCYA.js → logitron-logger.module-B_VVi3P9.js} +39 -4
- package/dist/logitron-logger.module-B_VVi3P9.js.map +1 -0
- package/dist/{logitron-logger.module-DdVy45xE.mjs → logitron-logger.module-BauCVR0-.mjs} +39 -4
- package/dist/logitron-logger.module-BauCVR0-.mjs.map +1 -0
- package/dist/{logitron-logger.module-Eaw6bH9M.d.mts → logitron-logger.module-Cu7QdkAm.d.mts} +32 -4
- package/dist/logitron-logger.module-Cu7QdkAm.d.mts.map +1 -0
- package/dist/{logitron-logger.module-CMRBDGwm.d.ts → logitron-logger.module-NI0xuTJj.d.ts} +32 -4
- package/dist/logitron-logger.module-NI0xuTJj.d.ts.map +1 -0
- package/dist/middleware.d.mts +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/nest.d.mts +2 -2
- package/dist/nest.d.ts +2 -2
- package/dist/nest.js +1 -1
- package/dist/nest.mjs +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/transports.d.mts +1 -1
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +1 -1
- package/dist/transports.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-Ium497V3.d.mts.map +0 -1
- package/dist/index-t-ActikQ.d.ts.map +0 -1
- package/dist/logitron-logger.module-B7CsnCYA.js.map +0 -1
- package/dist/logitron-logger.module-CMRBDGwm.d.ts.map +0 -1
- package/dist/logitron-logger.module-DdVy45xE.mjs.map +0 -1
- package/dist/logitron-logger.module-Eaw6bH9M.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -290,23 +290,54 @@ You can also define **custom levels** for your domain:
|
|
|
290
290
|
```typescript
|
|
291
291
|
const logger = createLogger({
|
|
292
292
|
appName: 'payments',
|
|
293
|
-
environment: 'production',
|
|
294
293
|
levelOptions: {
|
|
295
|
-
level: '
|
|
294
|
+
level: 'payment', // show everything down to 'payment'
|
|
296
295
|
levels: {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
error: 0,
|
|
297
|
+
warn: 1,
|
|
298
|
+
info: 2,
|
|
299
|
+
debug: 3,
|
|
300
|
+
// domain-specific levels — lower number = higher priority
|
|
301
|
+
payment: 1, // same priority as warn
|
|
302
|
+
audit: 2, // same priority as info
|
|
303
|
+
kafka: 2,
|
|
304
|
+
},
|
|
305
|
+
colors: {
|
|
306
|
+
error: 'red',
|
|
307
|
+
warn: 'yellow',
|
|
308
|
+
info: 'blue',
|
|
309
|
+
debug: 'green',
|
|
310
|
+
// IntelliSense now suggests 'payment' | 'audit' | 'kafka' as valid keys:
|
|
311
|
+
payment: 'brightYellow',
|
|
312
|
+
audit: 'magenta',
|
|
313
|
+
// kafka omitted → auto-palette assigns a visible color (cyan in this case)
|
|
300
314
|
},
|
|
301
315
|
},
|
|
302
316
|
});
|
|
303
317
|
|
|
304
318
|
// Custom level methods are available immediately, fully typed
|
|
305
|
-
await logger.
|
|
306
|
-
await logger.
|
|
319
|
+
await logger.payment('Charge captured', { orderId: 'ord_123', amount: 99.99 });
|
|
320
|
+
await logger.audit('Refund approved', { orderId: 'ord_123', by: 'admin' });
|
|
321
|
+
await logger.kafka('Message published', { topic: 'order.created' });
|
|
322
|
+
|
|
323
|
+
// logLevel() is the typed escape hatch — equivalent to the proxy methods above
|
|
324
|
+
await logger.logLevel('payment', 'Subscription renewed', { userId: 'usr_456' });
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**Auto-palette colors** — if you omit a color for a custom level, logixia assigns one automatically from the palette `magenta → cyan → yellow → green → blue` (cycling). No more "uncolored" custom levels blending into terminal noise.
|
|
328
|
+
|
|
329
|
+
**NestJS service IntelliSense** — `LogixiaLoggerService.create<T>(config)` carries the level names into the return type, so the IDE autocompletes `service.kafka(...)`, `service.payment(...)` etc. with the correct signature:
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
const svc = LogixiaLoggerService.create({
|
|
333
|
+
levelOptions: {
|
|
334
|
+
levels: { error: 0, warn: 1, info: 2, kafka: 3, payment: 4 },
|
|
335
|
+
colors: { error: 'red', kafka: 'magenta' }, // ← IDE suggests 'kafka' | 'payment' here
|
|
336
|
+
},
|
|
337
|
+
});
|
|
307
338
|
|
|
308
|
-
//
|
|
309
|
-
|
|
339
|
+
svc.kafka('Producer connected'); // ✅ fully typed, no 'as any'
|
|
340
|
+
svc.payment('Charge captured', { txnId }); // ✅
|
|
310
341
|
```
|
|
311
342
|
|
|
312
343
|
### Structured logging
|
|
@@ -1049,6 +1080,42 @@ export class OrdersService {
|
|
|
1049
1080
|
|
|
1050
1081
|
`LogixiaLoggerService` exposes the full `LogixiaLogger` API: `info`, `warn`, `error`, `debug`, `trace`, `verbose`, `logLevel`, `time`, `timeEnd`, `timeAsync`, `setLevel`, `getLevel`, `setContext`, `child`, `close`, `getCurrentTraceId`, and more.
|
|
1051
1082
|
|
|
1083
|
+
**Custom level proxy methods** — every key you add to `levelOptions.levels` automatically becomes a method on the service instance. Use `LogixiaLoggerService.create<T>(config)` (instead of `new`) to get full IntelliSense for those methods:
|
|
1084
|
+
|
|
1085
|
+
```typescript
|
|
1086
|
+
const logger = LogixiaLoggerService.create({
|
|
1087
|
+
levelOptions: {
|
|
1088
|
+
levels: { error: 0, warn: 1, info: 2, kafka: 2, mysql: 2, payment: 1 },
|
|
1089
|
+
colors: {
|
|
1090
|
+
error: 'red',
|
|
1091
|
+
warn: 'yellow',
|
|
1092
|
+
info: 'blue',
|
|
1093
|
+
kafka: 'magenta',
|
|
1094
|
+
payment: 'brightYellow',
|
|
1095
|
+
},
|
|
1096
|
+
},
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1099
|
+
// Methods are created at construction time — no casting required
|
|
1100
|
+
await logger.kafka('Consumer rebalanced', { groupId: 'app-group' });
|
|
1101
|
+
await logger.mysql('Slow query detected', { query, ms: 1240 });
|
|
1102
|
+
await logger.payment('Charge captured', { txnId, amount: 99.99 });
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
**TraceId** — with `traceId: true`, every log line carries a correlation ID automatically. Use `LogixiaContext.run()` to scope a trace to a block (the `TraceMiddleware` does this per-request automatically):
|
|
1106
|
+
|
|
1107
|
+
```typescript
|
|
1108
|
+
import { LogixiaContext } from 'logixia';
|
|
1109
|
+
|
|
1110
|
+
await LogixiaContext.run({ traceId: req.headers['x-request-id'] }, async () => {
|
|
1111
|
+
await logger.info('Request received'); // traceId: "abc-123" in every line
|
|
1112
|
+
await logger.kafka('Event published'); // same traceId
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
// Read the active traceId at any point
|
|
1116
|
+
const traceId = logger.getCurrentTraceId();
|
|
1117
|
+
```
|
|
1118
|
+
|
|
1052
1119
|
### @LogMethod decorator
|
|
1053
1120
|
|
|
1054
1121
|
Automatically logs method entry, exit, duration, and errors — no manual `try/catch` or `logger.debug` calls needed. Works on both sync and async methods. Reads the `logger` property from the class instance (the NestJS convention).
|