logixia 1.13.0 → 2.0.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 +81 -16
- package/dist/{async-context-CwBNMm2E.mjs → async-context-BzJrbfQs.mjs} +8 -4
- package/dist/async-context-BzJrbfQs.mjs.map +1 -0
- package/dist/{async-context-CSHWoHMB.js → async-context-DyQQYq3I.js} +8 -4
- package/dist/async-context-DyQQYq3I.js.map +1 -0
- package/dist/{azure-monitor.transport-CG7ClkYj.d.ts → azure-monitor.transport-Cn_3Usvu.d.ts} +2 -2
- package/dist/{azure-monitor.transport-CG7ClkYj.d.ts.map → azure-monitor.transport-Cn_3Usvu.d.ts.map} +1 -1
- package/dist/{azure-monitor.transport-Cm74kXZS.d.mts → azure-monitor.transport-D7Da4RAb.d.mts} +2 -2
- package/dist/{azure-monitor.transport-Cm74kXZS.d.mts.map → azure-monitor.transport-D7Da4RAb.d.mts.map} +1 -1
- package/dist/azure.d.mts +2 -2
- package/dist/azure.d.ts +2 -2
- package/dist/browser.d.mts +9 -0
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +9 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +43 -12
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +43 -12
- package/dist/browser.mjs.map +1 -1
- package/dist/{logitron-logger.module-Bs3XYZgF.mjs → builder-0gEzRopq.mjs} +383 -1021
- package/dist/builder-0gEzRopq.mjs.map +1 -0
- package/dist/{logitron-logger.module-BsDZR5BH.js → builder-D44QktIo.js} +411 -1155
- package/dist/builder-D44QktIo.js.map +1 -0
- package/dist/cli/index.js +130 -65
- package/dist/cloudwatch.d.mts +2 -2
- package/dist/cloudwatch.d.ts +2 -2
- package/dist/cloudwatch.js +2 -1
- package/dist/cloudwatch.mjs +2 -1
- package/dist/{cloudwatch.transport-pNBNWJLt.js → cloudwatch.transport-BO1ahxw-.js} +26 -19
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +1 -0
- package/dist/{cloudwatch.transport-yBwm4OeO.mjs → cloudwatch.transport-DZ6ies7g.mjs} +26 -19
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +1 -0
- package/dist/{cloudwatch.transport-CGHY4buE.d.mts → cloudwatch.transport-DsEq633o.d.ts} +9 -2
- package/dist/cloudwatch.transport-DsEq633o.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-DK_8cKd3.d.ts → cloudwatch.transport-UlyZFWMn.d.mts} +9 -2
- package/dist/cloudwatch.transport-UlyZFWMn.d.mts.map +1 -0
- package/dist/{coerce.utils-BN980Y9V.js → coerce.utils-B-LilukN.js} +1 -1
- package/dist/{coerce.utils-BN980Y9V.js.map → coerce.utils-B-LilukN.js.map} +1 -1
- package/dist/{coerce.utils-Dxv4_ikC.mjs → coerce.utils-Cu6IUTgX.mjs} +1 -1
- package/dist/{coerce.utils-Dxv4_ikC.mjs.map → coerce.utils-Cu6IUTgX.mjs.map} +1 -1
- package/dist/correlation.d.mts +24 -6
- package/dist/correlation.d.mts.map +1 -1
- package/dist/correlation.d.ts +24 -6
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +41 -16
- package/dist/correlation.js.map +1 -1
- package/dist/correlation.mjs +41 -16
- package/dist/correlation.mjs.map +1 -1
- package/dist/entry-fields-BJkuPnIg.mjs +30 -0
- package/dist/entry-fields-BJkuPnIg.mjs.map +1 -0
- package/dist/entry-fields-BvOLFlJ4.js +36 -0
- package/dist/entry-fields-BvOLFlJ4.js.map +1 -0
- package/dist/gcp.d.mts +2 -2
- package/dist/gcp.d.ts +2 -2
- package/dist/gcp.js +2 -1
- package/dist/gcp.mjs +2 -1
- package/dist/{gcp.transport-BOhkVKlI.d.ts → gcp.transport-B7oc97sG.d.ts} +2 -2
- package/dist/gcp.transport-B7oc97sG.d.ts.map +1 -0
- package/dist/{gcp.transport-SHdtc1n0.js → gcp.transport-CHV8MGgz.js} +5 -5
- package/dist/gcp.transport-CHV8MGgz.js.map +1 -0
- package/dist/{gcp.transport-BJuNRFe_.mjs → gcp.transport-DBX5TPIy.mjs} +5 -5
- package/dist/gcp.transport-DBX5TPIy.mjs.map +1 -0
- package/dist/{gcp.transport-Bi6CUqZR.d.mts → gcp.transport-GrJurKo8.d.mts} +2 -2
- package/dist/gcp.transport-GrJurKo8.d.mts.map +1 -0
- package/dist/{index-BPKwwERo.d.mts → index-3mw5gaCw.d.mts} +2 -2
- package/dist/{index-BPKwwERo.d.mts.map → index-3mw5gaCw.d.mts.map} +1 -1
- package/dist/{index-C1X-TE5I.d.ts → index-DhIoploR.d.ts} +2 -2
- package/dist/{index-C1X-TE5I.d.ts.map → index-DhIoploR.d.ts.map} +1 -1
- package/dist/index.d.mts +99 -137
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +99 -137
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +146 -510
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -431
- package/dist/index.mjs.map +1 -1
- package/dist/logitron-logger-BFDSO8Io.d.mts +257 -0
- package/dist/logitron-logger-BFDSO8Io.d.mts.map +1 -0
- package/dist/logitron-logger-UVeN-mQm.d.ts +257 -0
- package/dist/logitron-logger-UVeN-mQm.d.ts.map +1 -0
- package/dist/middleware.d.mts +11 -4
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +11 -4
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +148 -24
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +148 -24
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +481 -6
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +481 -6
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +884 -13
- package/dist/nest.js.map +1 -0
- package/dist/nest.mjs +863 -6
- package/dist/nest.mjs.map +1 -0
- package/dist/{search-CFQRISUv.mjs → search-BFbu_oVn.mjs} +35 -12
- package/dist/search-BFbu_oVn.mjs.map +1 -0
- package/dist/{search-njTI2hdo.js → search-C4V0OMEn.js} +35 -12
- package/dist/search-C4V0OMEn.js.map +1 -0
- package/dist/{search-DujhR94O.d.ts → search-CNh9uVwR.d.ts} +2 -3
- package/dist/search-CNh9uVwR.d.ts.map +1 -0
- package/dist/{search-CQOo-Iq6.d.mts → search-DXANsQ2n.d.mts} +2 -3
- package/dist/search-DXANsQ2n.d.mts.map +1 -0
- package/dist/search.d.mts +3 -3
- package/dist/search.d.ts +3 -3
- package/dist/search.js +2 -2
- package/dist/search.mjs +2 -2
- package/dist/slack.transport-BZzoXDPn.d.mts +112 -0
- package/dist/slack.transport-BZzoXDPn.d.mts.map +1 -0
- package/dist/slack.transport-BfJRouB2.js +654 -0
- package/dist/slack.transport-BfJRouB2.js.map +1 -0
- package/dist/slack.transport-Bzw7sucI.mjs +643 -0
- package/dist/slack.transport-Bzw7sucI.mjs.map +1 -0
- package/dist/slack.transport-CXjQYOes.d.ts +112 -0
- package/dist/slack.transport-CXjQYOes.d.ts.map +1 -0
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/trace.utils-CvXgaiQT.mjs +278 -0
- package/dist/trace.utils-CvXgaiQT.mjs.map +1 -0
- package/dist/trace.utils-DpBOLDtq.js +358 -0
- package/dist/trace.utils-DpBOLDtq.js.map +1 -0
- package/dist/{transport.manager-D6KL3t9V.mjs → transport.manager-BiuCAJd2.mjs} +526 -160
- package/dist/transport.manager-BiuCAJd2.mjs.map +1 -0
- package/dist/{transport.manager-BivyUTtU.js → transport.manager-CXbKKdVE.js} +537 -159
- package/dist/transport.manager-CXbKKdVE.js.map +1 -0
- package/dist/{transport.types-B5vcyv2k.d.mts → transport.types-BMnurPcc.d.mts} +23 -3
- package/dist/transport.types-BMnurPcc.d.mts.map +1 -0
- package/dist/{transport.types-BuY84TwO.d.ts → transport.types-CGoHpWQR.d.ts} +23 -3
- package/dist/transport.types-CGoHpWQR.d.ts.map +1 -0
- package/dist/transports.d.mts +50 -20
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +50 -20
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +9 -5
- package/dist/transports.mjs +8 -6
- package/dist/worker-entry.js +307 -55
- package/dist/worker.d.mts +2 -2
- package/dist/worker.d.ts +2 -2
- package/dist/worker.js +1 -1
- package/dist/worker.mjs +1 -1
- package/dist/{worker.transport-CfH6z37Z.js → worker.transport-BdPxu3PN.js} +1 -1
- package/dist/{worker.transport-CfH6z37Z.js.map → worker.transport-BdPxu3PN.js.map} +1 -1
- package/dist/{worker.transport-mKXgNK0L.d.ts → worker.transport-CdzSZJmw.d.ts} +2 -2
- package/dist/{worker.transport-mKXgNK0L.d.ts.map → worker.transport-CdzSZJmw.d.ts.map} +1 -1
- package/dist/{worker.transport-BP8Q28Z2.d.mts → worker.transport-JvGPog3C.d.mts} +2 -2
- package/dist/{worker.transport-BP8Q28Z2.d.mts.map → worker.transport-JvGPog3C.d.mts.map} +1 -1
- package/dist/{worker.transport-BhMyvqQ2.mjs → worker.transport-lPxO2MVL.mjs} +1 -1
- package/dist/{worker.transport-BhMyvqQ2.mjs.map → worker.transport-lPxO2MVL.mjs.map} +1 -1
- package/package.json +27 -14
- package/dist/.tsbuildinfo +0 -1
- package/dist/async-context-CSHWoHMB.js.map +0 -1
- package/dist/async-context-CwBNMm2E.mjs.map +0 -1
- package/dist/cloudwatch.transport-CGHY4buE.d.mts.map +0 -1
- package/dist/cloudwatch.transport-DK_8cKd3.d.ts.map +0 -1
- package/dist/cloudwatch.transport-pNBNWJLt.js.map +0 -1
- package/dist/cloudwatch.transport-yBwm4OeO.mjs.map +0 -1
- package/dist/gcp.transport-BJuNRFe_.mjs.map +0 -1
- package/dist/gcp.transport-BOhkVKlI.d.ts.map +0 -1
- package/dist/gcp.transport-Bi6CUqZR.d.mts.map +0 -1
- package/dist/gcp.transport-SHdtc1n0.js.map +0 -1
- package/dist/logitron-logger.module-BdG1Jnpk.d.mts +0 -618
- package/dist/logitron-logger.module-BdG1Jnpk.d.mts.map +0 -1
- package/dist/logitron-logger.module-Bs3XYZgF.mjs.map +0 -1
- package/dist/logitron-logger.module-BsDZR5BH.js.map +0 -1
- package/dist/logitron-logger.module-CbXy2gfW.d.ts +0 -618
- package/dist/logitron-logger.module-CbXy2gfW.d.ts.map +0 -1
- package/dist/search-CFQRISUv.mjs.map +0 -1
- package/dist/search-CQOo-Iq6.d.mts.map +0 -1
- package/dist/search-DujhR94O.d.ts.map +0 -1
- package/dist/search-njTI2hdo.js.map +0 -1
- package/dist/transport.manager-BivyUTtU.js.map +0 -1
- package/dist/transport.manager-D6KL3t9V.mjs.map +0 -1
- package/dist/transport.types-B5vcyv2k.d.mts.map +0 -1
- package/dist/transport.types-BuY84TwO.d.ts.map +0 -1
- package/scripts/postinstall.js +0 -61
package/README.md
CHANGED
|
@@ -673,7 +673,7 @@ const logger = createLogger({
|
|
|
673
673
|
analytics: {
|
|
674
674
|
datadog: {
|
|
675
675
|
apiKey: process.env.DD_API_KEY!,
|
|
676
|
-
site: 'datadoghq.com', // or 'datadoghq.eu', 'us3.datadoghq.com'
|
|
676
|
+
site: 'datadoghq.com', // or 'datadoghq.eu', 'us3.datadoghq.com', 'us5.datadoghq.com', 'ap1.datadoghq.com', 'ddog-gov.com'
|
|
677
677
|
service: 'api',
|
|
678
678
|
env: 'production',
|
|
679
679
|
enableLogs: true,
|
|
@@ -758,6 +758,31 @@ const logger = createLogger({
|
|
|
758
758
|
await logger.info('Order placed', { orderId: 'ord_789' });
|
|
759
759
|
```
|
|
760
760
|
|
|
761
|
+
### Slack and Discord webhook transports
|
|
762
|
+
|
|
763
|
+
Send alerts to a chat channel. Both default to `level: 'error'`, batch entries that arrive within `minIntervalMs` (default 1000) into one message, and cap a message at 10 entries (the rest are dropped and counted in the message).
|
|
764
|
+
|
|
765
|
+
```typescript
|
|
766
|
+
import { createLogger } from 'logixia';
|
|
767
|
+
import { DiscordTransport, SlackTransport } from 'logixia';
|
|
768
|
+
|
|
769
|
+
const logger = createLogger({
|
|
770
|
+
appName: 'api',
|
|
771
|
+
transports: {
|
|
772
|
+
custom: [
|
|
773
|
+
new SlackTransport({ webhookUrl: process.env.SLACK_WEBHOOK_URL!, level: 'error' }),
|
|
774
|
+
new DiscordTransport({ webhookUrl: process.env.DISCORD_WEBHOOK_URL!, level: 'warn' }),
|
|
775
|
+
],
|
|
776
|
+
},
|
|
777
|
+
});
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
- The webhook URL is a secret. It must be `https:` on `hooks.slack.com` (Slack) or `discord.com` / `discordapp.com` (Discord) unless you pass `allowCustomUrl: true`. It is never logged and never appears in error messages (only the host does).
|
|
781
|
+
- Logged text is escaped: Slack `&`, `<`, `>` (so `<!channel>` and `<@U123>` in log data cannot ping anyone); Discord markdown, plus `allowed_mentions: { parse: [] }` on every request.
|
|
782
|
+
- Platform limits are enforced by truncation (Slack header 150 and data 2,500 chars; Discord title 256, description 4,096, 25 fields, 6,000 per message).
|
|
783
|
+
- HTTP 429 waits for `Retry-After` (Discord: `retry_after`), then retries up to `maxRetries` (default 1). Other failures keep the batch queued with backoff; `flush()` rejects with a host-only error. The queue is bounded by `maxBufferSize` (default 1000, oldest dropped).
|
|
784
|
+
- Also available: `username`, `iconEmoji` (Slack), `avatarUrl` (Discord), `filter`, `formatter`, `flush()` and `close()` (flushes pending entries).
|
|
785
|
+
|
|
761
786
|
### Custom transport
|
|
762
787
|
|
|
763
788
|
Implement `ITransport` to send logs anywhere — Slack, PagerDuty, S3, an internal queue:
|
|
@@ -992,6 +1017,25 @@ class OrderService {
|
|
|
992
1017
|
|
|
993
1018
|
The default headers checked for an incoming trace ID (in priority order) are: `traceparent`, `x-trace-id`, `x-request-id`, `x-correlation-id`, `trace-id`.
|
|
994
1019
|
|
|
1020
|
+
### Hono
|
|
1021
|
+
|
|
1022
|
+
On Node, Hono needs nothing beyond `runWithTraceId()` — wrap `await next()` and every log line in the request carries the trace ID:
|
|
1023
|
+
|
|
1024
|
+
```typescript
|
|
1025
|
+
app.use(async (c, next) => {
|
|
1026
|
+
const traceId =
|
|
1027
|
+
extractTraceId({ headers: c.req.header() }, { header: DEFAULT_TRACE_HEADERS }) ??
|
|
1028
|
+
generateTraceId();
|
|
1029
|
+
await runWithTraceId(traceId, next);
|
|
1030
|
+
});
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
See [`examples/hono-example.ts`](./examples/hono-example.ts) (`npm run dev:hono`) for the full version.
|
|
1034
|
+
|
|
1035
|
+
### Next.js (App Router)
|
|
1036
|
+
|
|
1037
|
+
In a route handler on the Node.js runtime (`export const runtime = 'nodejs'`) the regular `logixia` entry works: wrap the handler body in `runWithTraceId(traceId, ...)`. See [`examples/nextjs/`](./examples/nextjs/) for a copy-paste route handler.
|
|
1038
|
+
|
|
995
1039
|
### NestJS trace middleware
|
|
996
1040
|
|
|
997
1041
|
The `TraceMiddleware` class integrates directly with NestJS's middleware system. `LogixiaLoggerModule.forRoot()` applies it automatically across all routes — no manual wiring needed:
|
|
@@ -1001,7 +1045,7 @@ The `TraceMiddleware` class integrates directly with NestJS's middleware system.
|
|
|
1001
1045
|
// For manual use in a custom module:
|
|
1002
1046
|
|
|
1003
1047
|
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
|
|
1004
|
-
import { TraceMiddleware } from 'logixia';
|
|
1048
|
+
import { TraceMiddleware } from 'logixia/nest';
|
|
1005
1049
|
|
|
1006
1050
|
@Module({})
|
|
1007
1051
|
export class AppModule implements NestModule {
|
|
@@ -1016,7 +1060,7 @@ export class AppModule implements NestModule {
|
|
|
1016
1060
|
Propagates trace IDs through Kafka message handlers. Reads `traceId` / `trace_id` / `x-trace-id` from the message body or headers and runs the handler inside that trace context:
|
|
1017
1061
|
|
|
1018
1062
|
```typescript
|
|
1019
|
-
import { KafkaTraceInterceptor } from 'logixia';
|
|
1063
|
+
import { KafkaTraceInterceptor } from 'logixia/nest';
|
|
1020
1064
|
import { UseInterceptors, Controller } from '@nestjs/common';
|
|
1021
1065
|
import { MessagePattern } from '@nestjs/microservices';
|
|
1022
1066
|
|
|
@@ -1038,7 +1082,7 @@ export class OrdersConsumer {
|
|
|
1038
1082
|
Propagates trace IDs through WebSocket event handlers. Reads `traceId` from the message body, event payload, or handshake query:
|
|
1039
1083
|
|
|
1040
1084
|
```typescript
|
|
1041
|
-
import { WebSocketTraceInterceptor } from 'logixia';
|
|
1085
|
+
import { WebSocketTraceInterceptor } from 'logixia/nest';
|
|
1042
1086
|
import { UseInterceptors, WebSocketGateway, SubscribeMessage } from '@nestjs/websockets';
|
|
1043
1087
|
|
|
1044
1088
|
@UseInterceptors(new WebSocketTraceInterceptor())
|
|
@@ -1060,6 +1104,11 @@ export class EventsGateway {
|
|
|
1060
1104
|
|
|
1061
1105
|
## NestJS integration
|
|
1062
1106
|
|
|
1107
|
+
> **Upgrading from 1.x:** since 2.0.0, everything NestJS-specific lives in `logixia/nest` only.
|
|
1108
|
+
> Change `import { LogixiaLoggerModule, LogixiaLoggerService, LogixiaExceptionFilter, InjectLogger, LogMethod } from 'logixia'`
|
|
1109
|
+
> to `... from 'logixia/nest'`. The root `logixia` entry no longer loads `@nestjs/common`, so plain Node, Express and Fastify apps
|
|
1110
|
+
> work without NestJS installed.
|
|
1111
|
+
|
|
1063
1112
|
Drop-in module with zero boilerplate. Registers `TraceMiddleware` for all routes, provides `LogixiaLoggerService`, `KafkaTraceInterceptor`, and `WebSocketTraceInterceptor` via the global DI container.
|
|
1064
1113
|
|
|
1065
1114
|
> **Full working example** — see [`examples/nestjs-app/`](./examples/nestjs-app/) for a complete NestJS app with Docker Compose (Postgres, MongoDB, Kafka, Kafdrop) that exercises every feature: `LogixiaLoggerModule`, `TraceMiddleware`, `LogixiaExceptionFilter`, `HttpLoggingInterceptor`, `WebSocketTraceInterceptor`, `KafkaTraceInterceptor`, `@LogMethod`, `child()` loggers, `timeAsync`, real Kafka producer + consumer.
|
|
@@ -1074,7 +1123,7 @@ Drop-in module with zero boilerplate. Registers `TraceMiddleware` for all routes
|
|
|
1074
1123
|
```typescript
|
|
1075
1124
|
// app.module.ts
|
|
1076
1125
|
import { Module } from '@nestjs/common';
|
|
1077
|
-
import { LogixiaLoggerModule } from 'logixia';
|
|
1126
|
+
import { LogixiaLoggerModule } from 'logixia/nest';
|
|
1078
1127
|
|
|
1079
1128
|
@Module({
|
|
1080
1129
|
imports: [
|
|
@@ -1120,7 +1169,7 @@ LogixiaLoggerModule.forRootAsync({
|
|
|
1120
1169
|
```typescript
|
|
1121
1170
|
// orders.service.ts
|
|
1122
1171
|
import { Injectable } from '@nestjs/common';
|
|
1123
|
-
import { LogixiaLoggerService } from 'logixia';
|
|
1172
|
+
import { LogixiaLoggerService } from 'logixia/nest';
|
|
1124
1173
|
|
|
1125
1174
|
@Injectable()
|
|
1126
1175
|
export class OrdersService {
|
|
@@ -1138,7 +1187,7 @@ export class OrdersService {
|
|
|
1138
1187
|
```typescript
|
|
1139
1188
|
// orders.module.ts
|
|
1140
1189
|
import { Module } from '@nestjs/common';
|
|
1141
|
-
import { LogixiaLoggerModule } from 'logixia';
|
|
1190
|
+
import { LogixiaLoggerModule } from 'logixia/nest';
|
|
1142
1191
|
import { OrdersService } from './orders.service';
|
|
1143
1192
|
|
|
1144
1193
|
@Module({
|
|
@@ -1151,7 +1200,7 @@ export class OrdersModule {}
|
|
|
1151
1200
|
```typescript
|
|
1152
1201
|
// orders.service.ts — inject the feature-scoped token
|
|
1153
1202
|
import { Inject, Injectable } from '@nestjs/common';
|
|
1154
|
-
import { LOGIXIA_LOGGER_PREFIX, LogixiaLoggerService } from 'logixia';
|
|
1203
|
+
import { LOGIXIA_LOGGER_PREFIX, LogixiaLoggerService } from 'logixia/nest';
|
|
1155
1204
|
|
|
1156
1205
|
@Injectable()
|
|
1157
1206
|
export class OrdersService {
|
|
@@ -1186,12 +1235,12 @@ await logger.mysql('Slow query detected', { query, ms: 1240 });
|
|
|
1186
1235
|
await logger.payment('Charge captured', { txnId, amount: 99.99 });
|
|
1187
1236
|
```
|
|
1188
1237
|
|
|
1189
|
-
**TraceId** — with `traceId: true`, every log line carries a correlation ID automatically. Use `
|
|
1238
|
+
**TraceId** — with `traceId: true`, every log line carries a correlation ID automatically. Use `runWithTraceId()` to scope a trace to a block (the `TraceMiddleware` does this per-request automatically):
|
|
1190
1239
|
|
|
1191
1240
|
```typescript
|
|
1192
|
-
import {
|
|
1241
|
+
import { runWithTraceId } from 'logixia';
|
|
1193
1242
|
|
|
1194
|
-
await
|
|
1243
|
+
await runWithTraceId(String(req.headers['x-request-id']), async () => {
|
|
1195
1244
|
await logger.info('Request received'); // traceId: "abc-123" in every line
|
|
1196
1245
|
await logger.kafka('Event published'); // same traceId
|
|
1197
1246
|
});
|
|
@@ -1206,7 +1255,7 @@ Automatically logs method entry, exit, duration, and errors — no manual `try/c
|
|
|
1206
1255
|
|
|
1207
1256
|
```typescript
|
|
1208
1257
|
import { Injectable } from '@nestjs/common';
|
|
1209
|
-
import { LogixiaLoggerService, LogMethod } from 'logixia';
|
|
1258
|
+
import { LogixiaLoggerService, LogMethod } from 'logixia/nest';
|
|
1210
1259
|
|
|
1211
1260
|
@Injectable()
|
|
1212
1261
|
export class PaymentService {
|
|
@@ -1243,7 +1292,7 @@ A global NestJS exception filter that automatically logs unhandled exceptions
|
|
|
1243
1292
|
```typescript
|
|
1244
1293
|
// main.ts
|
|
1245
1294
|
import { NestFactory } from '@nestjs/core';
|
|
1246
|
-
import { LogixiaExceptionFilter } from 'logixia';
|
|
1295
|
+
import { LogixiaExceptionFilter } from 'logixia/nest';
|
|
1247
1296
|
import { AppModule } from './app.module';
|
|
1248
1297
|
|
|
1249
1298
|
async function bootstrap() {
|
|
@@ -1258,7 +1307,7 @@ With `LogixiaLoggerModule` set up, inject the service directly so it logs to you
|
|
|
1258
1307
|
|
|
1259
1308
|
```typescript
|
|
1260
1309
|
import { APP_FILTER } from '@nestjs/core';
|
|
1261
|
-
import { LogixiaExceptionFilter, LogixiaLoggerService } from 'logixia';
|
|
1310
|
+
import { LogixiaExceptionFilter, LogixiaLoggerService } from 'logixia/nest';
|
|
1262
1311
|
|
|
1263
1312
|
// In AppModule providers:
|
|
1264
1313
|
{
|
|
@@ -1291,6 +1340,15 @@ The filter returns a consistent structured shape on every error:
|
|
|
1291
1340
|
}
|
|
1292
1341
|
```
|
|
1293
1342
|
|
|
1343
|
+
The `debug` block (stack trace, service, duration) is **off by default** and is never sent to clients unless you opt in, for example in local development only:
|
|
1344
|
+
|
|
1345
|
+
```typescript
|
|
1346
|
+
new LogixiaExceptionFilter(undefined, undefined, {
|
|
1347
|
+
exposeDebug: process.env.NODE_ENV === 'development',
|
|
1348
|
+
// exposeCause: true, // also include the underlying error message (may contain internal detail)
|
|
1349
|
+
});
|
|
1350
|
+
```
|
|
1351
|
+
|
|
1294
1352
|
And every log line carries `method`, `url`, `status`, `request_id` as structured fields — not a plain string:
|
|
1295
1353
|
|
|
1296
1354
|
```
|
|
@@ -1348,6 +1406,8 @@ const app = Fastify();
|
|
|
1348
1406
|
app.addHook('onRequest', correlationFastifyHook());
|
|
1349
1407
|
```
|
|
1350
1408
|
|
|
1409
|
+
> **Full working example** — see [`examples/fastify-example.ts`](./examples/fastify-example.ts) (`npm run dev:fastify`) for request logging, trace IDs and redaction on Fastify.
|
|
1410
|
+
|
|
1351
1411
|
### Outbound fetch / axios
|
|
1352
1412
|
|
|
1353
1413
|
Every outbound HTTP call made inside a correlated context automatically carries the `X-Correlation-ID` header.
|
|
@@ -1471,6 +1531,8 @@ const logger = new BrowserLogger({
|
|
|
1471
1531
|
});
|
|
1472
1532
|
```
|
|
1473
1533
|
|
|
1534
|
+
**Cloudflare Workers** — see [`examples/cloudflare-worker/`](./examples/cloudflare-worker/) for a Worker that logs JSON, tags each request with `child({ requestId })` and flushes a `BrowserRemoteTransport` with `ctx.waitUntil()`. Pass `flushIntervalMs: 0` to the transport: Workers don't allow timers at global scope.
|
|
1535
|
+
|
|
1474
1536
|
The following utilities from the main package are also re-exported from `logixia/browser` (safe for non-Node runtimes):
|
|
1475
1537
|
|
|
1476
1538
|
```typescript
|
|
@@ -2247,11 +2309,14 @@ import {
|
|
|
2247
2309
|
registerForShutdown, // (logger) => void
|
|
2248
2310
|
deregisterFromShutdown, // (logger) => void
|
|
2249
2311
|
resetShutdownHandlers, // () => void — useful in tests
|
|
2250
|
-
|
|
2312
|
+
} from 'logixia';
|
|
2313
|
+
|
|
2314
|
+
// NestJS extras (requires @nestjs/common):
|
|
2315
|
+
import {
|
|
2251
2316
|
InjectLogger, // @InjectLogger() parameter decorator
|
|
2252
2317
|
LogMethod, // @LogMethod() method decorator
|
|
2253
2318
|
LogixiaExceptionFilter, // global exception filter
|
|
2254
|
-
} from 'logixia';
|
|
2319
|
+
} from 'logixia/nest';
|
|
2255
2320
|
|
|
2256
2321
|
// Cloud transports (subpath imports):
|
|
2257
2322
|
import { CloudWatchTransport } from 'logixia/cloudwatch';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { d as sanitizeIncomingId } from "./trace.utils-CvXgaiQT.mjs";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
4
|
|
|
@@ -21,7 +22,10 @@ const LogixiaContext = {
|
|
|
21
22
|
set(fields) {
|
|
22
23
|
const store = _storage.getStore();
|
|
23
24
|
if (!store) return;
|
|
24
|
-
Object.
|
|
25
|
+
for (const key of Object.keys(fields)) {
|
|
26
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
27
|
+
store[key] = fields[key];
|
|
28
|
+
}
|
|
25
29
|
},
|
|
26
30
|
getStorage() {
|
|
27
31
|
return _storage;
|
|
@@ -40,7 +44,7 @@ const LogixiaContext = {
|
|
|
40
44
|
function createExpressContextMiddleware(options = {}) {
|
|
41
45
|
const { enrich, traceIdHeader = "x-trace-id" } = options;
|
|
42
46
|
return function logixiaContextMiddleware(req, _res, next) {
|
|
43
|
-
const base = { traceId: (req["headers"] ?? {})[traceIdHeader] ?? randomShortId() };
|
|
47
|
+
const base = { traceId: sanitizeIncomingId((req["headers"] ?? {})[traceIdHeader.toLowerCase()]) ?? randomShortId() };
|
|
44
48
|
LogixiaContext.run({
|
|
45
49
|
...base,
|
|
46
50
|
...enrich ? enrich(req) : {}
|
|
@@ -55,7 +59,7 @@ function createExpressContextMiddleware(options = {}) {
|
|
|
55
59
|
function createFastifyContextHook(options = {}) {
|
|
56
60
|
const { enrich, traceIdHeader = "x-trace-id" } = options;
|
|
57
61
|
return function logixiaFastifyHook(request, _reply, done) {
|
|
58
|
-
const base = { traceId: (request["headers"] ?? {})[traceIdHeader] ?? request["id"] ?? randomShortId() };
|
|
62
|
+
const base = { traceId: sanitizeIncomingId((request["headers"] ?? {})[traceIdHeader.toLowerCase()]) ?? sanitizeIncomingId(request["id"]) ?? randomShortId() };
|
|
59
63
|
LogixiaContext.run({
|
|
60
64
|
...base,
|
|
61
65
|
...enrich ? enrich(request) : {}
|
|
@@ -65,4 +69,4 @@ function createFastifyContextHook(options = {}) {
|
|
|
65
69
|
|
|
66
70
|
//#endregion
|
|
67
71
|
export { createExpressContextMiddleware as n, createFastifyContextHook as r, LogixiaContext as t };
|
|
68
|
-
//# sourceMappingURL=async-context-
|
|
72
|
+
//# sourceMappingURL=async-context-BzJrbfQs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-context-BzJrbfQs.mjs","names":["base: LogContext"],"sources":["../src/context/async-context.ts"],"sourcesContent":["/**\n * LogixiaContext — Zero-boilerplate AsyncLocalStorage context propagation.\n *\n * Lets every `logger.info()` call inside a context automatically pick up stored\n * fields (requestId, userId, tenantId, …) without passing them through every function.\n *\n * Works across `Promise.all`, `setTimeout`, and event emitters — anything that\n * inherits the async execution context.\n *\n * @example\n * ```ts\n * import { LogixiaContext } from 'logixia';\n *\n * // Wrap a request handler:\n * app.use((req, res, next) => {\n * LogixiaContext.run({ requestId: req.id, userId: req.user?.id }, next);\n * });\n *\n * // Anywhere deeper in the call tree:\n * async function processOrder(orderId: string) {\n * const ctx = LogixiaContext.get(); // { requestId, userId, orderId }\n * logger.info('Processing order', { orderId, ...ctx });\n * }\n * ```\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { randomUUID } from 'node:crypto';\n\nimport { sanitizeIncomingId } from '../utils/trace.utils';\n\n/** Generates an 8-character random ID using Node's crypto module. */\nfunction randomShortId(): string {\n return randomUUID().slice(0, 8);\n}\n\nexport interface LogContext {\n traceId?: string;\n spanId?: string;\n userId?: string;\n tenantId?: string;\n sessionId?: string;\n [key: string]: unknown;\n}\n\n// Module-level singleton so all loggers share the same ALS store.\nconst _storage = new AsyncLocalStorage<LogContext>();\n\nexport const LogixiaContext = {\n /**\n * Run `callback` inside an async context that carries `store` fields.\n * All loggers queried within `callback` (and its async descendants) will\n * automatically see these fields.\n *\n * @example\n * ```ts\n * LogixiaContext.run({ requestId: 'abc', userId: '42' }, async () => {\n * await processOrder(); // sees requestId + userId in every log\n * });\n * ```\n */\n run<T>(store: LogContext, callback: () => T): T {\n const parent = _storage.getStore() ?? {};\n return _storage.run({ ...parent, ...store }, callback);\n },\n\n /**\n * Return the context fields active in the current async scope.\n * Returns `undefined` when called outside any `LogixiaContext.run()`.\n */\n get(): LogContext | undefined {\n return _storage.getStore();\n },\n\n /**\n * Merge `fields` into the **existing** context for the current scope.\n * If called outside a `run()` context this is a no-op (logs a dev warning).\n */\n set(fields: Partial<LogContext>): void {\n const store = _storage.getStore();\n if (!store) {\n // Silently ignore — avoids crashing in code that may call setContext\n // before a request context is established (e.g. background jobs).\n return;\n }\n for (const key of Object.keys(fields)) {\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n store[key] = fields[key];\n }\n },\n\n /**\n * Retrieve the underlying `AsyncLocalStorage` instance.\n * Useful for advanced use-cases like custom middleware.\n */\n getStorage(): AsyncLocalStorage<LogContext> {\n return _storage;\n },\n};\n\n/**\n * Create an Express/Connect-compatible middleware that wraps each request in\n * a `LogixiaContext.run()` scope populated with common request fields.\n *\n * @example\n * ```ts\n * import { createExpressContextMiddleware } from 'logixia';\n * app.use(createExpressContextMiddleware());\n * ```\n */\nexport function createExpressContextMiddleware(\n options: {\n /** Extract additional fields from the request. */\n enrich?: (req: Record<string, unknown>) => Partial<LogContext>;\n /** Header to read the traceId from. Default: 'x-trace-id'. */\n traceIdHeader?: string;\n } = {}\n) {\n const { enrich, traceIdHeader = 'x-trace-id' } = options;\n\n return function logixiaContextMiddleware(\n req: Record<string, unknown>,\n _res: unknown,\n next: () => void\n ): void {\n const headers = (req['headers'] ?? {}) as Record<string, string | undefined>;\n const traceId = sanitizeIncomingId(headers[traceIdHeader.toLowerCase()]) ?? randomShortId();\n const base: LogContext = { traceId };\n LogixiaContext.run({ ...base, ...(enrich ? enrich(req) : {}) }, next);\n };\n}\n\n/**\n * Create a Fastify lifecycle hook that wraps each request in a context scope.\n *\n * Register with `fastify.addHook('onRequest', createFastifyContextHook())`.\n */\nexport function createFastifyContextHook(\n options: {\n enrich?: (request: Record<string, unknown>) => Partial<LogContext>;\n traceIdHeader?: string;\n } = {}\n) {\n const { enrich, traceIdHeader = 'x-trace-id' } = options;\n\n return function logixiaFastifyHook(\n request: Record<string, unknown>,\n _reply: unknown,\n done: () => void\n ): void {\n const headers = (request['headers'] ?? {}) as Record<string, string | undefined>;\n const traceId =\n sanitizeIncomingId(headers[traceIdHeader.toLowerCase()]) ??\n sanitizeIncomingId(request['id']) ??\n randomShortId();\n const base: LogContext = { traceId };\n LogixiaContext.run({ ...base, ...(enrich ? enrich(request) : {}) }, done);\n };\n}\n"],"mappings":";;;;;;AAgCA,SAAS,gBAAwB;AAC/B,QAAO,YAAY,CAAC,MAAM,GAAG,EAAE;;AAajC,MAAM,WAAW,IAAI,mBAA+B;AAEpD,MAAa,iBAAiB;CAa5B,IAAO,OAAmB,UAAsB;EAC9C,MAAM,SAAS,SAAS,UAAU,IAAI,EAAE;AACxC,SAAO,SAAS,IAAI;GAAE,GAAG;GAAQ,GAAG;GAAO,EAAE,SAAS;;CAOxD,MAA8B;AAC5B,SAAO,SAAS,UAAU;;CAO5B,IAAI,QAAmC;EACrC,MAAM,QAAQ,SAAS,UAAU;AACjC,MAAI,CAAC,MAGH;AAEF,OAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;AACrC,OAAI,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ,YAAa;AACzE,SAAM,OAAO,OAAO;;;CAQxB,aAA4C;AAC1C,SAAO;;CAEV;;;;;;;;;;;AAYD,SAAgB,+BACd,UAKI,EAAE,EACN;CACA,MAAM,EAAE,QAAQ,gBAAgB,iBAAiB;AAEjD,QAAO,SAAS,yBACd,KACA,MACA,MACM;EAGN,MAAMA,OAAmB,EAAE,SADX,oBADC,IAAI,cAAc,EAAE,EACM,cAAc,aAAa,EAAE,IAAI,eAAe,EACvD;AACpC,iBAAe,IAAI;GAAE,GAAG;GAAM,GAAI,SAAS,OAAO,IAAI,GAAG,EAAE;GAAG,EAAE,KAAK;;;;;;;;AASzE,SAAgB,yBACd,UAGI,EAAE,EACN;CACA,MAAM,EAAE,QAAQ,gBAAgB,iBAAiB;AAEjD,QAAO,SAAS,mBACd,SACA,QACA,MACM;EAMN,MAAMA,OAAmB,EAAE,SAHzB,oBAFe,QAAQ,cAAc,EAAE,EAEZ,cAAc,aAAa,EAAE,IACxD,mBAAmB,QAAQ,MAAM,IACjC,eAAe,EACmB;AACpC,iBAAe,IAAI;GAAE,GAAG;GAAM,GAAI,SAAS,OAAO,QAAQ,GAAG,EAAE;GAAG,EAAE,KAAK"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
const require_trace_utils = require('./trace.utils-DpBOLDtq.js');
|
|
2
3
|
let node_crypto = require("node:crypto");
|
|
3
4
|
node_crypto = require_chunk.__toESM(node_crypto);
|
|
4
5
|
let node_async_hooks = require("node:async_hooks");
|
|
@@ -24,7 +25,10 @@ const LogixiaContext = {
|
|
|
24
25
|
set(fields) {
|
|
25
26
|
const store = _storage.getStore();
|
|
26
27
|
if (!store) return;
|
|
27
|
-
Object.
|
|
28
|
+
for (const key of Object.keys(fields)) {
|
|
29
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
30
|
+
store[key] = fields[key];
|
|
31
|
+
}
|
|
28
32
|
},
|
|
29
33
|
getStorage() {
|
|
30
34
|
return _storage;
|
|
@@ -43,7 +47,7 @@ const LogixiaContext = {
|
|
|
43
47
|
function createExpressContextMiddleware(options = {}) {
|
|
44
48
|
const { enrich, traceIdHeader = "x-trace-id" } = options;
|
|
45
49
|
return function logixiaContextMiddleware(req, _res, next) {
|
|
46
|
-
const base = { traceId: (req["headers"] ?? {})[traceIdHeader] ?? randomShortId() };
|
|
50
|
+
const base = { traceId: require_trace_utils.sanitizeIncomingId((req["headers"] ?? {})[traceIdHeader.toLowerCase()]) ?? randomShortId() };
|
|
47
51
|
LogixiaContext.run({
|
|
48
52
|
...base,
|
|
49
53
|
...enrich ? enrich(req) : {}
|
|
@@ -58,7 +62,7 @@ function createExpressContextMiddleware(options = {}) {
|
|
|
58
62
|
function createFastifyContextHook(options = {}) {
|
|
59
63
|
const { enrich, traceIdHeader = "x-trace-id" } = options;
|
|
60
64
|
return function logixiaFastifyHook(request, _reply, done) {
|
|
61
|
-
const base = { traceId: (request["headers"] ?? {})[traceIdHeader] ?? request["id"] ?? randomShortId() };
|
|
65
|
+
const base = { traceId: require_trace_utils.sanitizeIncomingId((request["headers"] ?? {})[traceIdHeader.toLowerCase()]) ?? require_trace_utils.sanitizeIncomingId(request["id"]) ?? randomShortId() };
|
|
62
66
|
LogixiaContext.run({
|
|
63
67
|
...base,
|
|
64
68
|
...enrich ? enrich(request) : {}
|
|
@@ -85,4 +89,4 @@ Object.defineProperty(exports, 'createFastifyContextHook', {
|
|
|
85
89
|
return createFastifyContextHook;
|
|
86
90
|
}
|
|
87
91
|
});
|
|
88
|
-
//# sourceMappingURL=async-context-
|
|
92
|
+
//# sourceMappingURL=async-context-DyQQYq3I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-context-DyQQYq3I.js","names":["AsyncLocalStorage","base: LogContext","sanitizeIncomingId"],"sources":["../src/context/async-context.ts"],"sourcesContent":["/**\n * LogixiaContext — Zero-boilerplate AsyncLocalStorage context propagation.\n *\n * Lets every `logger.info()` call inside a context automatically pick up stored\n * fields (requestId, userId, tenantId, …) without passing them through every function.\n *\n * Works across `Promise.all`, `setTimeout`, and event emitters — anything that\n * inherits the async execution context.\n *\n * @example\n * ```ts\n * import { LogixiaContext } from 'logixia';\n *\n * // Wrap a request handler:\n * app.use((req, res, next) => {\n * LogixiaContext.run({ requestId: req.id, userId: req.user?.id }, next);\n * });\n *\n * // Anywhere deeper in the call tree:\n * async function processOrder(orderId: string) {\n * const ctx = LogixiaContext.get(); // { requestId, userId, orderId }\n * logger.info('Processing order', { orderId, ...ctx });\n * }\n * ```\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { randomUUID } from 'node:crypto';\n\nimport { sanitizeIncomingId } from '../utils/trace.utils';\n\n/** Generates an 8-character random ID using Node's crypto module. */\nfunction randomShortId(): string {\n return randomUUID().slice(0, 8);\n}\n\nexport interface LogContext {\n traceId?: string;\n spanId?: string;\n userId?: string;\n tenantId?: string;\n sessionId?: string;\n [key: string]: unknown;\n}\n\n// Module-level singleton so all loggers share the same ALS store.\nconst _storage = new AsyncLocalStorage<LogContext>();\n\nexport const LogixiaContext = {\n /**\n * Run `callback` inside an async context that carries `store` fields.\n * All loggers queried within `callback` (and its async descendants) will\n * automatically see these fields.\n *\n * @example\n * ```ts\n * LogixiaContext.run({ requestId: 'abc', userId: '42' }, async () => {\n * await processOrder(); // sees requestId + userId in every log\n * });\n * ```\n */\n run<T>(store: LogContext, callback: () => T): T {\n const parent = _storage.getStore() ?? {};\n return _storage.run({ ...parent, ...store }, callback);\n },\n\n /**\n * Return the context fields active in the current async scope.\n * Returns `undefined` when called outside any `LogixiaContext.run()`.\n */\n get(): LogContext | undefined {\n return _storage.getStore();\n },\n\n /**\n * Merge `fields` into the **existing** context for the current scope.\n * If called outside a `run()` context this is a no-op (logs a dev warning).\n */\n set(fields: Partial<LogContext>): void {\n const store = _storage.getStore();\n if (!store) {\n // Silently ignore — avoids crashing in code that may call setContext\n // before a request context is established (e.g. background jobs).\n return;\n }\n for (const key of Object.keys(fields)) {\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n store[key] = fields[key];\n }\n },\n\n /**\n * Retrieve the underlying `AsyncLocalStorage` instance.\n * Useful for advanced use-cases like custom middleware.\n */\n getStorage(): AsyncLocalStorage<LogContext> {\n return _storage;\n },\n};\n\n/**\n * Create an Express/Connect-compatible middleware that wraps each request in\n * a `LogixiaContext.run()` scope populated with common request fields.\n *\n * @example\n * ```ts\n * import { createExpressContextMiddleware } from 'logixia';\n * app.use(createExpressContextMiddleware());\n * ```\n */\nexport function createExpressContextMiddleware(\n options: {\n /** Extract additional fields from the request. */\n enrich?: (req: Record<string, unknown>) => Partial<LogContext>;\n /** Header to read the traceId from. Default: 'x-trace-id'. */\n traceIdHeader?: string;\n } = {}\n) {\n const { enrich, traceIdHeader = 'x-trace-id' } = options;\n\n return function logixiaContextMiddleware(\n req: Record<string, unknown>,\n _res: unknown,\n next: () => void\n ): void {\n const headers = (req['headers'] ?? {}) as Record<string, string | undefined>;\n const traceId = sanitizeIncomingId(headers[traceIdHeader.toLowerCase()]) ?? randomShortId();\n const base: LogContext = { traceId };\n LogixiaContext.run({ ...base, ...(enrich ? enrich(req) : {}) }, next);\n };\n}\n\n/**\n * Create a Fastify lifecycle hook that wraps each request in a context scope.\n *\n * Register with `fastify.addHook('onRequest', createFastifyContextHook())`.\n */\nexport function createFastifyContextHook(\n options: {\n enrich?: (request: Record<string, unknown>) => Partial<LogContext>;\n traceIdHeader?: string;\n } = {}\n) {\n const { enrich, traceIdHeader = 'x-trace-id' } = options;\n\n return function logixiaFastifyHook(\n request: Record<string, unknown>,\n _reply: unknown,\n done: () => void\n ): void {\n const headers = (request['headers'] ?? {}) as Record<string, string | undefined>;\n const traceId =\n sanitizeIncomingId(headers[traceIdHeader.toLowerCase()]) ??\n sanitizeIncomingId(request['id']) ??\n randomShortId();\n const base: LogContext = { traceId };\n LogixiaContext.run({ ...base, ...(enrich ? enrich(request) : {}) }, done);\n };\n}\n"],"mappings":";;;;;;;;;AAgCA,SAAS,gBAAwB;AAC/B,qCAAmB,CAAC,MAAM,GAAG,EAAE;;AAajC,MAAM,WAAW,IAAIA,oCAA+B;AAEpD,MAAa,iBAAiB;CAa5B,IAAO,OAAmB,UAAsB;EAC9C,MAAM,SAAS,SAAS,UAAU,IAAI,EAAE;AACxC,SAAO,SAAS,IAAI;GAAE,GAAG;GAAQ,GAAG;GAAO,EAAE,SAAS;;CAOxD,MAA8B;AAC5B,SAAO,SAAS,UAAU;;CAO5B,IAAI,QAAmC;EACrC,MAAM,QAAQ,SAAS,UAAU;AACjC,MAAI,CAAC,MAGH;AAEF,OAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;AACrC,OAAI,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ,YAAa;AACzE,SAAM,OAAO,OAAO;;;CAQxB,aAA4C;AAC1C,SAAO;;CAEV;;;;;;;;;;;AAYD,SAAgB,+BACd,UAKI,EAAE,EACN;CACA,MAAM,EAAE,QAAQ,gBAAgB,iBAAiB;AAEjD,QAAO,SAAS,yBACd,KACA,MACA,MACM;EAGN,MAAMC,OAAmB,EAAE,SADXC,wCADC,IAAI,cAAc,EAAE,EACM,cAAc,aAAa,EAAE,IAAI,eAAe,EACvD;AACpC,iBAAe,IAAI;GAAE,GAAG;GAAM,GAAI,SAAS,OAAO,IAAI,GAAG,EAAE;GAAG,EAAE,KAAK;;;;;;;;AASzE,SAAgB,yBACd,UAGI,EAAE,EACN;CACA,MAAM,EAAE,QAAQ,gBAAgB,iBAAiB;AAEjD,QAAO,SAAS,mBACd,SACA,QACA,MACM;EAMN,MAAMD,OAAmB,EAAE,SAHzBC,wCAFe,QAAQ,cAAc,EAAE,EAEZ,cAAc,aAAa,EAAE,IACxDA,uCAAmB,QAAQ,MAAM,IACjC,eAAe,EACmB;AACpC,iBAAe,IAAI;GAAE,GAAG;GAAM,GAAI,SAAS,OAAO,QAAQ,GAAG,EAAE;GAAG,EAAE,KAAK"}
|
package/dist/{azure-monitor.transport-CG7ClkYj.d.ts → azure-monitor.transport-Cn_3Usvu.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-
|
|
1
|
+
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-CGoHpWQR.js";
|
|
2
2
|
|
|
3
3
|
//#region src/transports/azure-monitor.transport.d.ts
|
|
4
4
|
|
|
@@ -59,4 +59,4 @@ declare class AzureMonitorTransport implements IAsyncTransport {
|
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
61
61
|
export { AzureMonitorTransportConfig as n, AzureMonitorTransport as t };
|
|
62
|
-
//# sourceMappingURL=azure-monitor.transport-
|
|
62
|
+
//# sourceMappingURL=azure-monitor.transport-Cn_3Usvu.d.ts.map
|
package/dist/{azure-monitor.transport-CG7ClkYj.d.ts.map → azure-monitor.transport-Cn_3Usvu.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-monitor.transport-
|
|
1
|
+
{"version":3,"file":"azure-monitor.transport-Cn_3Usvu.d.ts","names":[],"sources":["../src/transports/azure-monitor.transport.ts"],"sourcesContent":[],"mappings":";;;;UAkDiB,2BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCJ,qBAAA,YAAiC;;;;;;;;;;;;;;;;sBAmBxB;eAwBP;WAKJ;;;;;;WASM"}
|
package/dist/{azure-monitor.transport-Cm74kXZS.d.mts → azure-monitor.transport-D7Da4RAb.d.mts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-
|
|
1
|
+
import { p as TransportLogEntry, s as IAsyncTransport } from "./transport.types-BMnurPcc.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/transports/azure-monitor.transport.d.ts
|
|
4
4
|
|
|
@@ -59,4 +59,4 @@ declare class AzureMonitorTransport implements IAsyncTransport {
|
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
61
61
|
export { AzureMonitorTransportConfig as n, AzureMonitorTransport as t };
|
|
62
|
-
//# sourceMappingURL=azure-monitor.transport-
|
|
62
|
+
//# sourceMappingURL=azure-monitor.transport-D7Da4RAb.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-monitor.transport-
|
|
1
|
+
{"version":3,"file":"azure-monitor.transport-D7Da4RAb.d.mts","names":[],"sources":["../src/transports/azure-monitor.transport.ts"],"sourcesContent":[],"mappings":";;;;UAkDiB,2BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCJ,qBAAA,YAAiC;;;;;;;;;;;;;;;;sBAmBxB;eAwBP;WAKJ;;;;;;WASM"}
|
package/dist/azure.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./transport.types-
|
|
2
|
-
import { n as AzureMonitorTransportConfig, t as AzureMonitorTransport } from "./azure-monitor.transport-
|
|
1
|
+
import "./transport.types-BMnurPcc.mjs";
|
|
2
|
+
import { n as AzureMonitorTransportConfig, t as AzureMonitorTransport } from "./azure-monitor.transport-D7Da4RAb.mjs";
|
|
3
3
|
export { AzureMonitorTransport, AzureMonitorTransportConfig };
|
package/dist/azure.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./transport.types-
|
|
2
|
-
import { n as AzureMonitorTransportConfig, t as AzureMonitorTransport } from "./azure-monitor.transport-
|
|
1
|
+
import "./transport.types-CGoHpWQR.js";
|
|
2
|
+
import { n as AzureMonitorTransportConfig, t as AzureMonitorTransport } from "./azure-monitor.transport-Cn_3Usvu.js";
|
|
3
3
|
export { AzureMonitorTransport, AzureMonitorTransportConfig };
|
package/dist/browser.d.mts
CHANGED
|
@@ -332,6 +332,9 @@ declare class BrowserRemoteTransport implements IBrowserTransport {
|
|
|
332
332
|
private readonly maxBufferSize;
|
|
333
333
|
private readonly headers;
|
|
334
334
|
private batch;
|
|
335
|
+
private keepaliveSupported;
|
|
336
|
+
private failedFlushCount;
|
|
337
|
+
private lastFlushError;
|
|
335
338
|
private timer;
|
|
336
339
|
private droppedEntries;
|
|
337
340
|
constructor(options: {
|
|
@@ -360,8 +363,14 @@ declare class BrowserRemoteTransport implements IBrowserTransport {
|
|
|
360
363
|
* non-retryable HTTP status (a 4xx other than 429).
|
|
361
364
|
*/
|
|
362
365
|
get dropped(): number;
|
|
366
|
+
/** Number of flush attempts that failed with a network error and were re-buffered. */
|
|
367
|
+
get failedFlushes(): number;
|
|
368
|
+
/** The most recent network error from a failed flush, if any. */
|
|
369
|
+
get lastError(): unknown;
|
|
363
370
|
write(entry: BrowserLogEntry): void;
|
|
364
371
|
flush(): Promise<void>;
|
|
372
|
+
private send;
|
|
373
|
+
private recordFailure;
|
|
365
374
|
private scheduleFlush;
|
|
366
375
|
/**
|
|
367
376
|
* Stop the flush timer and flush remaining entries. Without the final flush,
|
package/dist/browser.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.mts","names":[],"sources":["../src/utils/otel.ts","../src/utils/typed-logger.ts","../src/browser.ts"],"sourcesContent":[],"mappings":";;AAsCA;AAWA;AA8DA;AA2CA;AA8BA;AA2BA;;;;ACtKA;AAEA;AAQA;;;;;AAIA;;;;;;;AAkBA;;;;;;;AAuCA;;;;AAE+B,UDhFd,eAAA,CCgFc;EAA0B;EAC1B,OAAA,EAAA,MAAA;EAA0B;EACzB,MAAA,EAAA,MAAA;EAA0B;EACvB,UAAA,EAAA,MAAA;EAA0B;EAC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sBAchB,0BAA0B;;;;;;;;;;;;;;iBAiDhC,mBAAA,UAA6B,sBAAsB;;;;;;;;;;cAmCtD,eAAa"}
|
package/dist/browser.d.ts
CHANGED
|
@@ -332,6 +332,9 @@ declare class BrowserRemoteTransport implements IBrowserTransport {
|
|
|
332
332
|
private readonly maxBufferSize;
|
|
333
333
|
private readonly headers;
|
|
334
334
|
private batch;
|
|
335
|
+
private keepaliveSupported;
|
|
336
|
+
private failedFlushCount;
|
|
337
|
+
private lastFlushError;
|
|
335
338
|
private timer;
|
|
336
339
|
private droppedEntries;
|
|
337
340
|
constructor(options: {
|
|
@@ -360,8 +363,14 @@ declare class BrowserRemoteTransport implements IBrowserTransport {
|
|
|
360
363
|
* non-retryable HTTP status (a 4xx other than 429).
|
|
361
364
|
*/
|
|
362
365
|
get dropped(): number;
|
|
366
|
+
/** Number of flush attempts that failed with a network error and were re-buffered. */
|
|
367
|
+
get failedFlushes(): number;
|
|
368
|
+
/** The most recent network error from a failed flush, if any. */
|
|
369
|
+
get lastError(): unknown;
|
|
363
370
|
write(entry: BrowserLogEntry): void;
|
|
364
371
|
flush(): Promise<void>;
|
|
372
|
+
private send;
|
|
373
|
+
private recordFailure;
|
|
365
374
|
private scheduleFlush;
|
|
366
375
|
/**
|
|
367
376
|
* Stop the flush timer and flush remaining entries. Without the final flush,
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","names":[],"sources":["../src/utils/otel.ts","../src/utils/typed-logger.ts","../src/browser.ts"],"sourcesContent":[],"mappings":";;AAsCA;AAWA;AA8DA;AA2CA;AA8BA;AA2BA;;;;ACtKA;AAEA;AAQA;;;;;AAIA;;;;;;;AAkBA;;;;;;;AAuCA;;;;AAE+B,UDhFd,eAAA,CCgFc;EAA0B;EAC1B,OAAA,EAAA,MAAA;EAA0B;EACzB,MAAA,EAAA,MAAA;EAA0B;EACvB,UAAA,EAAA,MAAA;EAA0B;EAC5B,SAAA,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AA0B;;;;;;;;;;;;;;iBAiDhC,mBAAA,UAA6B,sBAAsB;;;;;;;;;;cAmCtD,eAAa"}
|
package/dist/browser.js
CHANGED
|
@@ -377,6 +377,9 @@ function validateRemoteUrl(raw) {
|
|
|
377
377
|
function byteLength(s) {
|
|
378
378
|
return new TextEncoder().encode(s).length;
|
|
379
379
|
}
|
|
380
|
+
function isKeepaliveError(error) {
|
|
381
|
+
return error instanceof Error && /keepalive/i.test(error.message);
|
|
382
|
+
}
|
|
380
383
|
/**
|
|
381
384
|
* Browser transport that batches log entries and sends them to a remote
|
|
382
385
|
* HTTP endpoint via `fetch` (available in all modern browsers and Edge runtimes).
|
|
@@ -398,6 +401,8 @@ var BrowserRemoteTransport = class {
|
|
|
398
401
|
constructor(options) {
|
|
399
402
|
this.name = "browser-remote";
|
|
400
403
|
this.batch = [];
|
|
404
|
+
this.keepaliveSupported = true;
|
|
405
|
+
this.failedFlushCount = 0;
|
|
401
406
|
this.timer = null;
|
|
402
407
|
this.droppedEntries = 0;
|
|
403
408
|
this.url = validateRemoteUrl(options.url);
|
|
@@ -416,6 +421,14 @@ var BrowserRemoteTransport = class {
|
|
|
416
421
|
get dropped() {
|
|
417
422
|
return this.droppedEntries;
|
|
418
423
|
}
|
|
424
|
+
/** Number of flush attempts that failed with a network error and were re-buffered. */
|
|
425
|
+
get failedFlushes() {
|
|
426
|
+
return this.failedFlushCount;
|
|
427
|
+
}
|
|
428
|
+
/** The most recent network error from a failed flush, if any. */
|
|
429
|
+
get lastError() {
|
|
430
|
+
return this.lastFlushError;
|
|
431
|
+
}
|
|
419
432
|
write(entry) {
|
|
420
433
|
this.batch.push(entry);
|
|
421
434
|
while (this.batch.length > this.maxBufferSize) {
|
|
@@ -431,18 +444,20 @@ var BrowserRemoteTransport = class {
|
|
|
431
444
|
const keepalive = byteLength(body) < 6e4;
|
|
432
445
|
let res;
|
|
433
446
|
try {
|
|
434
|
-
res = await
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
447
|
+
res = await this.send(body, this.keepaliveSupported ? keepalive : void 0);
|
|
448
|
+
} catch (error) {
|
|
449
|
+
if (this.keepaliveSupported && isKeepaliveError(error)) {
|
|
450
|
+
this.keepaliveSupported = false;
|
|
451
|
+
try {
|
|
452
|
+
res = await this.send(body);
|
|
453
|
+
} catch (retryError) {
|
|
454
|
+
this.recordFailure(entries, retryError);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
this.recordFailure(entries, error);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
446
461
|
}
|
|
447
462
|
if (!res.ok) {
|
|
448
463
|
if (res.status >= 500 || res.status === 429) this.batch.unshift(...entries);
|
|
@@ -451,6 +466,22 @@ var BrowserRemoteTransport = class {
|
|
|
451
466
|
}
|
|
452
467
|
}
|
|
453
468
|
}
|
|
469
|
+
send(body, keepalive) {
|
|
470
|
+
return fetch(this.url, {
|
|
471
|
+
method: "POST",
|
|
472
|
+
headers: {
|
|
473
|
+
"Content-Type": "application/json",
|
|
474
|
+
...this.headers
|
|
475
|
+
},
|
|
476
|
+
body,
|
|
477
|
+
...keepalive !== void 0 ? { keepalive } : {}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
recordFailure(entries, error) {
|
|
481
|
+
this.batch.unshift(...entries);
|
|
482
|
+
this.failedFlushCount += 1;
|
|
483
|
+
this.lastFlushError = error;
|
|
484
|
+
}
|
|
454
485
|
scheduleFlush() {
|
|
455
486
|
if (this.flushIntervalMs <= 0) return;
|
|
456
487
|
if (typeof globalThis !== "undefined" && typeof globalThis["setInterval"] === "function") this.timer = setInterval(() => {
|