@logscopeai/logscope 0.1.0-beta.2 → 0.1.0-beta.4
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 +174 -179
- package/dist/client/create-logscope-client.js.map +1 -1
- package/dist/config/config-guards.d.ts +12 -0
- package/dist/config/config-guards.js +34 -1
- package/dist/config/config-guards.js.map +1 -1
- package/dist/winston/map-winston-level.d.ts +2 -0
- package/dist/winston/map-winston-level.js +20 -0
- package/dist/winston/map-winston-level.js.map +1 -0
- package/dist/winston/transport.d.ts +20 -0
- package/dist/winston/transport.js +173 -0
- package/dist/winston/transport.js.map +1 -0
- package/dist/winston.d.ts +4 -0
- package/dist/winston.js +11 -0
- package/dist/winston.js.map +1 -0
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -1,83 +1,61 @@
|
|
|
1
|
-
# logscope
|
|
1
|
+
# @logscopeai/logscope
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Supported beta for the Logscope ingestion SDK.
|
|
4
4
|
>
|
|
5
|
-
>
|
|
6
|
-
>
|
|
7
|
-
>
|
|
5
|
+
> `@logscopeai/logscope` is the official Node.js SDK for sending application logs to the Logscope
|
|
6
|
+
> Ingestion API. The package is pre-GA, but its documented public behavior is treated as
|
|
7
|
+
> compatibility-sensitive and is maintained with a conservative, fail-safe posture.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`@logscopeai/logscope` lets Node.js applications capture logs, normalize them to the ingestion
|
|
10
|
+
schema, apply optional client-side filtering, batch delivery asynchronously, and forward logs to
|
|
11
|
+
Logscope without throwing into user code.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## Supported Beta Posture
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
- Supported beta means the SDK is intended for real integrations, not only disposable local demos.
|
|
16
|
+
- Supported beta does not mean GA:
|
|
17
|
+
- internal implementation may still evolve;
|
|
18
|
+
- future beta releases may add or refine surface area;
|
|
19
|
+
- users should still pin versions deliberately and validate upgrades.
|
|
20
|
+
- Public behavior that is documented for consumers is treated as compatibility-sensitive.
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## Early Development Mode
|
|
18
|
-
|
|
19
|
-
During early development phases, `logscope` is expected to be executed locally using:
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
npm link
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
This allows the SDK to be developed and tested inside a consuming service before being published to npm.
|
|
26
|
-
|
|
27
|
-
The intended import pattern is:
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
import { Logscope } from 'logscope';
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Compatibility with `npm link` is a design requirement.
|
|
34
|
-
|
|
35
|
-
---
|
|
22
|
+
See `docs/supported-beta-policy.md` for the support and deprecation policy, and
|
|
23
|
+
`docs/compatibility-contract.md` for the supported-beta compatibility baseline.
|
|
36
24
|
|
|
37
25
|
## What This Package Does
|
|
38
26
|
|
|
39
27
|
- Captures logs from:
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
- Normalizes logs to the
|
|
45
|
-
- Applies optional
|
|
46
|
-
- Batches logs
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
---
|
|
28
|
+
- the manual SDK API;
|
|
29
|
+
- optional console capture;
|
|
30
|
+
- pino via `@logscopeai/logscope/pino`;
|
|
31
|
+
- winston via `@logscopeai/logscope/winston`.
|
|
32
|
+
- Normalizes logs to the ingestion schema.
|
|
33
|
+
- Applies optional level-based filtering before batching.
|
|
34
|
+
- Batches logs in memory and sends them asynchronously.
|
|
35
|
+
- Retries retriable delivery failures with backoff.
|
|
36
|
+
- Avoids throwing into user code.
|
|
51
37
|
|
|
52
38
|
## What This Package Does Not Do
|
|
53
39
|
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
- Replace structured logging frameworks
|
|
60
|
-
|
|
61
|
-
---
|
|
40
|
+
- Validate API keys semantically against server-side policy.
|
|
41
|
+
- Persist logs to disk.
|
|
42
|
+
- Provide storage, analytics, dashboarding, or querying.
|
|
43
|
+
- Replace structured logging frameworks.
|
|
44
|
+
- Offer GA/SLA guarantees.
|
|
62
45
|
|
|
63
46
|
## Installation
|
|
64
47
|
|
|
65
|
-
```
|
|
66
|
-
npm install logscope
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Or during development:
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
npm link logscope
|
|
48
|
+
```bash
|
|
49
|
+
npm install @logscopeai/logscope
|
|
73
50
|
```
|
|
74
51
|
|
|
75
|
-
|
|
52
|
+
For workspace development and local package iteration, `npm link` remains supported. See
|
|
53
|
+
`docs/local-development.md` for the canonical SDK-side local link and endpoint guidance.
|
|
76
54
|
|
|
77
|
-
##
|
|
55
|
+
## Quick Start (`Logscope`)
|
|
78
56
|
|
|
79
57
|
```ts
|
|
80
|
-
import { Logscope } from 'logscope';
|
|
58
|
+
import { Logscope } from '@logscopeai/logscope';
|
|
81
59
|
|
|
82
60
|
const logscope = new Logscope({
|
|
83
61
|
apiKey: process.env.LOGSCOPE_API_KEY!,
|
|
@@ -93,7 +71,7 @@ logscope.error('Payment failed', { orderId: 123 });
|
|
|
93
71
|
https://ingestion.logscopeai.com
|
|
94
72
|
```
|
|
95
73
|
|
|
96
|
-
For
|
|
74
|
+
For local or test environments, override `ingestionBaseUrl` explicitly:
|
|
97
75
|
|
|
98
76
|
```ts
|
|
99
77
|
const logscope = new Logscope({
|
|
@@ -102,10 +80,12 @@ const logscope = new Logscope({
|
|
|
102
80
|
});
|
|
103
81
|
```
|
|
104
82
|
|
|
105
|
-
Compatibility
|
|
83
|
+
## Compatibility Factory (`createLogscopeClient`)
|
|
84
|
+
|
|
85
|
+
The compatibility entrypoint remains available:
|
|
106
86
|
|
|
107
87
|
```ts
|
|
108
|
-
import { createLogscopeClient } from 'logscope';
|
|
88
|
+
import { createLogscopeClient } from '@logscopeai/logscope';
|
|
109
89
|
|
|
110
90
|
const logscope = createLogscopeClient({
|
|
111
91
|
apiKey: process.env.LOGSCOPE_API_KEY!,
|
|
@@ -126,105 +106,124 @@ const logscope = createLogscopeClient({
|
|
|
126
106
|
});
|
|
127
107
|
```
|
|
128
108
|
|
|
129
|
-
|
|
109
|
+
`createLogscopeClient` and `Logscope` expose the same manual log methods:
|
|
110
|
+
|
|
111
|
+
- `trace`
|
|
112
|
+
- `debug`
|
|
113
|
+
- `info`
|
|
114
|
+
- `warn`
|
|
115
|
+
- `error`
|
|
116
|
+
- `fatal`
|
|
130
117
|
|
|
131
|
-
|
|
118
|
+
## Client Configuration
|
|
132
119
|
|
|
133
|
-
|
|
120
|
+
Client config highlights:
|
|
121
|
+
|
|
122
|
+
- `apiKey` is required.
|
|
123
|
+
- `ingestionBaseUrl` is the canonical client override for local/dev/test routing.
|
|
124
|
+
- `endpoint` is still accepted on the root client as a deprecated compatibility alias.
|
|
125
|
+
- `captureConsole` is opt-in and disabled by default.
|
|
126
|
+
- `context.source` is optional and deprecated as required caller input; omitted values fall back to
|
|
127
|
+
deterministic source `unknown`.
|
|
128
|
+
- `runtime` controls batching and retry quantities through validated safe defaults.
|
|
129
|
+
|
|
130
|
+
Runtime delivery knobs:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
runtime: {
|
|
134
|
+
maxBatchSize?: number; // default: 50, bounded to ingestion contract max
|
|
135
|
+
flushIntervalMs?: number; // default: 2000
|
|
136
|
+
maxRetries?: number; // default: 3
|
|
137
|
+
retryBaseDelayMs?: number; // default: 250
|
|
138
|
+
retryMaxDelayMs?: number; // default: 2000
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Invalid runtime overrides are ignored safely and fallback to defaults without throwing.
|
|
143
|
+
|
|
144
|
+
## Validation And Safety Guarantees
|
|
134
145
|
|
|
135
146
|
Runtime guards are applied before delivery:
|
|
136
147
|
|
|
137
|
-
- Required config fields are validated
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
- Invalid required config triggers a single safe warning and switches to a no-op fallback pipeline.
|
|
148
|
+
- Required config fields are validated before pipeline creation.
|
|
149
|
+
- Invalid required config triggers a safe warning and switches the client/transport into no-op
|
|
150
|
+
fallback behavior.
|
|
141
151
|
- Warning diagnostics never include secret values such as API keys.
|
|
142
|
-
- `ingestionBaseUrl` is optional
|
|
143
|
-
|
|
144
|
-
- The SDK does not expose
|
|
152
|
+
- `ingestionBaseUrl` is optional on the root client and falls back to the production default when
|
|
153
|
+
omitted or invalid.
|
|
154
|
+
- The SDK does not expose a client-owned `environment` routing field.
|
|
145
155
|
|
|
146
156
|
Normalization enforces ingestion constraints:
|
|
147
157
|
|
|
148
158
|
- `message` is deterministically truncated to `<= 2048` characters.
|
|
149
159
|
- `metadata` is normalized to JSON-safe content and dropped if serialized size is `> 2048` bytes.
|
|
150
160
|
|
|
151
|
-
|
|
161
|
+
Fail-safe expectations:
|
|
152
162
|
|
|
153
|
-
|
|
163
|
+
- The SDK must never throw into user code.
|
|
164
|
+
- Filtering happens before batching.
|
|
165
|
+
- `401` results warn once.
|
|
166
|
+
- `429` and `500` results retry with backoff.
|
|
167
|
+
- Batches are dropped after max retries are exhausted.
|
|
154
168
|
|
|
155
|
-
## Public Types
|
|
169
|
+
## Public Types And Utilities
|
|
156
170
|
|
|
157
|
-
The root entrypoint
|
|
171
|
+
The root entrypoint exports the class API, compatibility factory, shared types, constants, and
|
|
172
|
+
normalization utility:
|
|
158
173
|
|
|
159
174
|
```ts
|
|
160
|
-
import { Logscope, normalizeLog } from 'logscope';
|
|
175
|
+
import { Logscope, createLogscopeClient, normalizeLog } from '@logscopeai/logscope';
|
|
161
176
|
import type {
|
|
162
177
|
IngestionLogEntry,
|
|
163
178
|
LogLevel,
|
|
164
179
|
LogscopeClient,
|
|
165
180
|
LogscopeConfig,
|
|
166
181
|
LogscopeInitConfig,
|
|
167
|
-
} from 'logscope';
|
|
182
|
+
} from '@logscopeai/logscope';
|
|
168
183
|
```
|
|
169
184
|
|
|
170
|
-
`normalizeLog` converts SDK log input into ingestion-safe entries using
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## Filtering Logs
|
|
175
|
-
|
|
176
|
-
Users may restrict which logs are sent to Logscope:
|
|
185
|
+
`normalizeLog` converts SDK log input into ingestion-safe entries using:
|
|
177
186
|
|
|
178
187
|
```ts
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
{
|
|
189
|
+
source,
|
|
190
|
+
level,
|
|
191
|
+
timestamp,
|
|
192
|
+
message,
|
|
193
|
+
metadata?,
|
|
181
194
|
}
|
|
182
195
|
```
|
|
183
196
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
If `logFilter.levels` is configured as an empty array (`[]`), all logs are filtered out.
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Runtime Delivery Configuration
|
|
197
|
+
## Filtering Logs
|
|
191
198
|
|
|
192
|
-
|
|
199
|
+
`logFilter.levels` restricts which levels enter the delivery pipeline:
|
|
193
200
|
|
|
194
201
|
```ts
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
flushIntervalMs?: number; // default: 2000
|
|
198
|
-
maxRetries?: number; // default: 3
|
|
199
|
-
retryBaseDelayMs?: number; // default: 250
|
|
200
|
-
retryMaxDelayMs?: number; // default: 2000
|
|
202
|
+
logFilter: {
|
|
203
|
+
levels: ['warn', 'error'],
|
|
201
204
|
}
|
|
202
205
|
```
|
|
203
206
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
+
- If no filter is configured, all logs are sent.
|
|
208
|
+
- If `logFilter.levels` is an empty array, all logs are filtered out.
|
|
207
209
|
|
|
208
210
|
## Console Capture
|
|
209
211
|
|
|
210
212
|
`captureConsole` is disabled by default.
|
|
211
213
|
|
|
212
|
-
When
|
|
213
|
-
|
|
214
|
-
- `console.log` (mapped to `info`)
|
|
215
|
-
- `console.info` (mapped to `info`)
|
|
216
|
-
- `console.warn` (mapped to `warn`)
|
|
217
|
-
- `console.error` (mapped to `error`)
|
|
214
|
+
When enabled, the SDK wraps:
|
|
218
215
|
|
|
219
|
-
|
|
216
|
+
- `console.log` -> `info`
|
|
217
|
+
- `console.info` -> `info`
|
|
218
|
+
- `console.warn` -> `warn`
|
|
219
|
+
- `console.error` -> `error`
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
Original console behavior is preserved, and captured entries flow through the same filtering and
|
|
222
|
+
batching pipeline used by the manual client API.
|
|
222
223
|
|
|
223
|
-
##
|
|
224
|
+
## Pino Integration
|
|
224
225
|
|
|
225
|
-
Logscope does not intercept pino automatically.
|
|
226
|
-
|
|
227
|
-
Instead, it provides an explicit transport:
|
|
226
|
+
Logscope does not intercept pino automatically. Use the explicit transport subpath:
|
|
228
227
|
|
|
229
228
|
```ts
|
|
230
229
|
import pino from 'pino';
|
|
@@ -233,7 +232,7 @@ const logger = pino({
|
|
|
233
232
|
transport: {
|
|
234
233
|
targets: [
|
|
235
234
|
{
|
|
236
|
-
target: 'logscope/pino',
|
|
235
|
+
target: '@logscopeai/logscope/pino',
|
|
237
236
|
options: {
|
|
238
237
|
apiKey: process.env.LOGSCOPE_API_KEY,
|
|
239
238
|
endpoint: 'http://localhost:3000',
|
|
@@ -245,97 +244,93 @@ const logger = pino({
|
|
|
245
244
|
});
|
|
246
245
|
```
|
|
247
246
|
|
|
248
|
-
|
|
247
|
+
Pino transport notes:
|
|
249
248
|
|
|
250
|
-
|
|
249
|
+
- transport option name remains `endpoint`;
|
|
250
|
+
- `source` is required on the transport surface;
|
|
251
|
+
- pino levels `10/20/30/40/50/60` map to Logscope levels
|
|
252
|
+
`trace/debug/info/warn/error/fatal`;
|
|
253
|
+
- filtering still happens before batching.
|
|
251
254
|
|
|
252
|
-
##
|
|
255
|
+
## Winston Integration
|
|
253
256
|
|
|
254
|
-
|
|
257
|
+
Logscope does not patch winston globally. Use the explicit transport subpath:
|
|
255
258
|
|
|
259
|
+
```ts
|
|
260
|
+
import { createLogger, format } from 'winston';
|
|
261
|
+
import { createWinstonTransport } from '@logscopeai/logscope/winston';
|
|
262
|
+
|
|
263
|
+
const logger = createLogger({
|
|
264
|
+
level: 'info',
|
|
265
|
+
format: format.combine(format.timestamp()),
|
|
266
|
+
transports: [
|
|
267
|
+
createWinstonTransport({
|
|
268
|
+
apiKey: process.env.LOGSCOPE_API_KEY!,
|
|
269
|
+
endpoint: 'http://localhost:3000',
|
|
270
|
+
source: 'billing-api',
|
|
271
|
+
logFilter: {
|
|
272
|
+
levels: ['warn', 'error'],
|
|
273
|
+
},
|
|
274
|
+
}),
|
|
275
|
+
],
|
|
276
|
+
});
|
|
256
277
|
```
|
|
278
|
+
|
|
279
|
+
Winston transport notes:
|
|
280
|
+
|
|
281
|
+
- transport option name remains `endpoint`;
|
|
282
|
+
- `source` is required on the transport surface;
|
|
283
|
+
- default npm levels map to Logscope levels
|
|
284
|
+
`error/warn/info/info/debug/debug/trace`;
|
|
285
|
+
- filtering still happens before batching.
|
|
286
|
+
|
|
287
|
+
## Ingestion Contract Summary
|
|
288
|
+
|
|
289
|
+
The SDK sends logs to:
|
|
290
|
+
|
|
291
|
+
```text
|
|
257
292
|
POST /api/logs/ingest
|
|
258
293
|
```
|
|
259
294
|
|
|
260
295
|
Using header:
|
|
261
296
|
|
|
262
|
-
```
|
|
297
|
+
```text
|
|
263
298
|
x-api-key: <LOGSCOPE_API_KEY>
|
|
264
299
|
```
|
|
265
300
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
Transport status handling is classified as:
|
|
301
|
+
Response handling:
|
|
269
302
|
|
|
270
303
|
- `202` -> success
|
|
271
|
-
- `400` / `413` -> drop
|
|
304
|
+
- `400` / `413` -> drop batch
|
|
272
305
|
- `401` -> unauthorized warning path
|
|
273
306
|
- `429` / `500` -> retry with backoff
|
|
274
307
|
- retriable batches are dropped after max retries
|
|
275
308
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
## Status
|
|
309
|
+
## Current Limits And Non-Goals
|
|
279
310
|
|
|
280
|
-
|
|
311
|
+
- Supported beta, not GA.
|
|
312
|
+
- No disk persistence or local buffering.
|
|
313
|
+
- No sampling, tracing, or OpenTelemetry surface.
|
|
314
|
+
- No hidden global patching of pino or winston.
|
|
315
|
+
- No synchronous I/O.
|
|
281
316
|
|
|
282
|
-
|
|
283
|
-
- Under active development
|
|
284
|
-
- Not production-ready
|
|
285
|
-
- Subject to API changes
|
|
317
|
+
## Testing And Build
|
|
286
318
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
## Testing Conventions
|
|
290
|
-
|
|
291
|
-
Unit tests must be co-located with the files they validate.
|
|
292
|
-
|
|
293
|
-
Use either `.test.ts` or `.spec.ts` next to the implementation file, for example:
|
|
294
|
-
|
|
295
|
-
```text
|
|
296
|
-
src/
|
|
297
|
-
dirA/
|
|
298
|
-
file.ts
|
|
299
|
-
file.spec.ts
|
|
300
|
-
dirB/
|
|
301
|
-
otherFile.ts
|
|
302
|
-
otherFile.test.ts
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
Run tests with:
|
|
319
|
+
Run the standard verification flow from a clean checkout:
|
|
306
320
|
|
|
307
321
|
```bash
|
|
322
|
+
npm ci
|
|
308
323
|
npm test
|
|
324
|
+
npm run build
|
|
309
325
|
```
|
|
310
326
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
```bash
|
|
314
|
-
npm run test:coverage
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
---
|
|
327
|
+
Unit tests are co-located with the files they validate and coverage is enforced through Vitest.
|
|
318
328
|
|
|
319
329
|
## Additional Documentation
|
|
320
330
|
|
|
331
|
+
- Support and deprecation policy: `docs/supported-beta-policy.md`
|
|
332
|
+
- SDK compatibility contract: `docs/compatibility-contract.md`
|
|
333
|
+
- Local development and `npm link` guidance: `docs/local-development.md`
|
|
334
|
+
- Release verification checklist: `docs/release-verification.md`
|
|
321
335
|
- Hardening and coverage matrix: `docs/hardening-and-testing.md`
|
|
322
336
|
- Formatting and lint workflow: `docs/linting.md`
|
|
323
|
-
|
|
324
|
-
## Local usage with `npm link`
|
|
325
|
-
|
|
326
|
-
To run the package locally in other repositories, use `npm link`:
|
|
327
|
-
|
|
328
|
-
Steps:
|
|
329
|
-
|
|
330
|
-
1. In this repository:
|
|
331
|
-
|
|
332
|
-
```
|
|
333
|
-
npm link
|
|
334
|
-
npm run build -- --watch
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
2. In the consuming repository:
|
|
338
|
-
|
|
339
|
-
```
|
|
340
|
-
npm link logscope
|
|
341
|
-
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-logscope-client.js","sourceRoot":"","sources":["../../src/client/create-logscope-client.ts"],"names":[],"mappings":";;;AAAA,gEAAqF;AAErF,2DAGiC;AACjC,mDAAqF;AACrF,mEAAqE;AACrE,gFAA2E;AAM3E,+CAAiD;AAEjD,MAAM,4BAA4B,GAChC,mFAAmF,CAAC;AACtF,MAAM,+BAA+B,
|
|
1
|
+
{"version":3,"file":"create-logscope-client.js","sourceRoot":"","sources":["../../src/client/create-logscope-client.ts"],"names":[],"mappings":";;;AAAA,gEAAqF;AAErF,2DAGiC;AACjC,mDAAqF;AACrF,mEAAqE;AACrE,gFAA2E;AAM3E,+CAAiD;AAEjD,MAAM,4BAA4B,GAChC,mFAAmF,CAAC;AACtF,MAAM,+BAA+B,GAAG,yDAAyD,CAAC;AAqBlG,MAAM,kBAAkB,GAAG,GAAqB,EAAE;IAChD,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;QACjB,QAAQ,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;QACxB,IAAI,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KACrB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,GAAqC,EAAE;IACvE,MAAM,SAAS,GA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,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IACE,aAAa,CAAC,cAAc,KAAK,IAAI;QACrC,aAAa,CAAC,OAAO;QACrB,YAAY,CAAC,mBAAmB,KAAK,SAAS,EAC9C,CAAC;QACD,IAAI,CAAC;YACH,YAAY,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;IACH,CAAC;IAED,OAAO,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAC;AACvC,CAAC,CAAC;AA1EW,QAAA,4BAA4B,gCA0EvC;AAEK,MAAM,oBAAoB,GAAG,CAAC,MAAsB,EAAkB,EAAE;IAC7E,OAAO,IAAA,oCAA4B,EAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B"}
|
|
@@ -3,6 +3,7 @@ import { type ResolvedRuntimeConfig } from './runtime-config';
|
|
|
3
3
|
import type { LogFilterConfig } from '../types';
|
|
4
4
|
type ClientRequiredField = 'apiKey';
|
|
5
5
|
type PinoRequiredField = 'apiKey' | 'endpoint' | 'source';
|
|
6
|
+
type WinstonRequiredField = 'apiKey' | 'endpoint' | 'source';
|
|
6
7
|
interface GuardResult {
|
|
7
8
|
isValid: boolean;
|
|
8
9
|
}
|
|
@@ -24,8 +25,19 @@ export interface PinoOptionsGuardResult extends GuardResult {
|
|
|
24
25
|
logFilter?: LogFilterConfig;
|
|
25
26
|
invalidFields: ReadonlyArray<PinoRequiredField>;
|
|
26
27
|
}
|
|
28
|
+
export interface WinstonOptionsGuardResult extends GuardResult {
|
|
29
|
+
apiKey: string;
|
|
30
|
+
endpoint: string;
|
|
31
|
+
source: string;
|
|
32
|
+
flushIntervalMs?: number;
|
|
33
|
+
retryPolicy?: Partial<RetryPolicy>;
|
|
34
|
+
logFilter?: LogFilterConfig;
|
|
35
|
+
invalidFields: ReadonlyArray<WinstonRequiredField>;
|
|
36
|
+
}
|
|
27
37
|
export declare const buildInvalidClientConfigWarning: (invalidFields: ReadonlyArray<ClientRequiredField>) => string;
|
|
28
38
|
export declare const buildInvalidPinoOptionsWarning: (invalidFields: ReadonlyArray<PinoRequiredField>) => string;
|
|
39
|
+
export declare const buildInvalidWinstonOptionsWarning: (invalidFields: ReadonlyArray<WinstonRequiredField>) => string;
|
|
29
40
|
export declare const guardLogscopeClientConfig: (config: unknown) => ClientConfigGuardResult;
|
|
30
41
|
export declare const guardPinoTransportOptions: (options: unknown) => PinoOptionsGuardResult;
|
|
42
|
+
export declare const guardWinstonTransportOptions: (options: unknown) => WinstonOptionsGuardResult;
|
|
31
43
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.guardPinoTransportOptions = exports.guardLogscopeClientConfig = exports.buildInvalidPinoOptionsWarning = exports.buildInvalidClientConfigWarning = void 0;
|
|
3
|
+
exports.guardWinstonTransportOptions = exports.guardPinoTransportOptions = exports.guardLogscopeClientConfig = exports.buildInvalidWinstonOptionsWarning = exports.buildInvalidPinoOptionsWarning = exports.buildInvalidClientConfigWarning = void 0;
|
|
4
4
|
const runtime_config_1 = require("./runtime-config");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const isRecord = (value) => {
|
|
@@ -66,6 +66,10 @@ const buildInvalidPinoOptionsWarning = (invalidFields) => {
|
|
|
66
66
|
return `[logscope] Invalid pino transport configuration. SDK fallback mode enabled. Missing or invalid required field(s): ${invalidFields.join(', ')}.`;
|
|
67
67
|
};
|
|
68
68
|
exports.buildInvalidPinoOptionsWarning = buildInvalidPinoOptionsWarning;
|
|
69
|
+
const buildInvalidWinstonOptionsWarning = (invalidFields) => {
|
|
70
|
+
return `[logscope] Invalid winston transport configuration. SDK fallback mode enabled. Missing or invalid required field(s): ${invalidFields.join(', ')}.`;
|
|
71
|
+
};
|
|
72
|
+
exports.buildInvalidWinstonOptionsWarning = buildInvalidWinstonOptionsWarning;
|
|
69
73
|
const guardLogscopeClientConfig = (config) => {
|
|
70
74
|
const apiKey = safeGetProperty(config, 'apiKey');
|
|
71
75
|
const ingestionBaseUrlCandidate = safeGetProperty(config, 'ingestionBaseUrl');
|
|
@@ -125,4 +129,33 @@ const guardPinoTransportOptions = (options) => {
|
|
|
125
129
|
};
|
|
126
130
|
};
|
|
127
131
|
exports.guardPinoTransportOptions = guardPinoTransportOptions;
|
|
132
|
+
const guardWinstonTransportOptions = (options) => {
|
|
133
|
+
const apiKey = safeGetProperty(options, 'apiKey');
|
|
134
|
+
const endpoint = safeGetProperty(options, 'endpoint');
|
|
135
|
+
const source = safeGetProperty(options, 'source');
|
|
136
|
+
const flushIntervalMsValue = safeGetProperty(options, 'flushIntervalMs');
|
|
137
|
+
const retryPolicyValue = safeGetProperty(options, 'retryPolicy');
|
|
138
|
+
const logFilter = normalizeLogFilter(safeGetProperty(options, 'logFilter'));
|
|
139
|
+
const invalidFields = [];
|
|
140
|
+
if (!isNonEmptyString(apiKey)) {
|
|
141
|
+
invalidFields.push('apiKey');
|
|
142
|
+
}
|
|
143
|
+
if (!isNonEmptyString(endpoint)) {
|
|
144
|
+
invalidFields.push('endpoint');
|
|
145
|
+
}
|
|
146
|
+
if (!isNonEmptyString(source)) {
|
|
147
|
+
invalidFields.push('source');
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
isValid: invalidFields.length === 0,
|
|
151
|
+
apiKey: isNonEmptyString(apiKey) ? apiKey : '',
|
|
152
|
+
endpoint: isNonEmptyString(endpoint) ? endpoint : '',
|
|
153
|
+
source: isNonEmptyString(source) ? source : constants_1.SAFE_FALLBACK_SOURCE,
|
|
154
|
+
flushIntervalMs: typeof flushIntervalMsValue === 'number' ? flushIntervalMsValue : undefined,
|
|
155
|
+
retryPolicy: normalizeRetryPolicy(retryPolicyValue),
|
|
156
|
+
logFilter,
|
|
157
|
+
invalidFields,
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
exports.guardWinstonTransportOptions = guardWinstonTransportOptions;
|
|
128
161
|
//# sourceMappingURL=config-guards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-guards.js","sourceRoot":"","sources":["../../src/config/config-guards.ts"],"names":[],"mappings":";;;AACA,qDAI0B;AAC1B,4CAA4F;
|
|
1
|
+
{"version":3,"file":"config-guards.js","sourceRoot":"","sources":["../../src/config/config-guards.ts"],"names":[],"mappings":";;;AACA,qDAI0B;AAC1B,4CAA4F;AA2C5F,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAwB,EAAE;IACxD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,KAAc,EAAE,GAAW,EAAW,EAAE;IAC/D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAmB,EAAE;IAC3D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE;IACvD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,sBAAU,CAAC,QAAQ,CAAC,KAAiB,CAAC,CAAC;AAC7E,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAA+B,EAAE;IACzE,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEhD,IAA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C,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;QAC5F,WAAW,EAAE,oBAAoB,CAAC,gBAAgB,CAAC;QACnD,SAAS;QACT,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AAhCW,QAAA,4BAA4B,gCAgCvC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapWinstonLevel = void 0;
|
|
4
|
+
const WINSTON_LEVEL_MAP = {
|
|
5
|
+
error: 'error',
|
|
6
|
+
warn: 'warn',
|
|
7
|
+
info: 'info',
|
|
8
|
+
http: 'info',
|
|
9
|
+
verbose: 'debug',
|
|
10
|
+
debug: 'debug',
|
|
11
|
+
silly: 'trace',
|
|
12
|
+
};
|
|
13
|
+
const mapWinstonLevel = (value) => {
|
|
14
|
+
if (typeof value !== 'string') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return WINSTON_LEVEL_MAP[value.trim().toLowerCase()];
|
|
18
|
+
};
|
|
19
|
+
exports.mapWinstonLevel = mapWinstonLevel;
|
|
20
|
+
//# sourceMappingURL=map-winston-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-winston-level.js","sourceRoot":"","sources":["../../src/winston/map-winston-level.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,GAAuC;IAC5D,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;CACf,CAAC;AAEK,MAAM,eAAe,GAAG,CAAC,KAAc,EAAwB,EAAE;IACtE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import TransportStream from 'winston-transport';
|
|
2
|
+
import type { RetryPolicy } from '../retry/retry-policy';
|
|
3
|
+
import { type BatchingPipeline, type CreateBatchingPipelineInput } from '../pipeline/pipeline';
|
|
4
|
+
import type { IngestionRequestResult, SendIngestionRequestInput } from '../transport/transport-types';
|
|
5
|
+
import type { LogFilterConfig } from '../types';
|
|
6
|
+
export interface LogscopeWinstonTransportOptions {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
endpoint: string;
|
|
9
|
+
source: string;
|
|
10
|
+
logFilter?: LogFilterConfig;
|
|
11
|
+
flushIntervalMs?: number;
|
|
12
|
+
retryPolicy?: Partial<RetryPolicy>;
|
|
13
|
+
}
|
|
14
|
+
export interface WinstonTransportDependencies {
|
|
15
|
+
sendBatch: (input: SendIngestionRequestInput) => Promise<IngestionRequestResult>;
|
|
16
|
+
warn: (message: string) => void;
|
|
17
|
+
createPipeline?: (input: CreateBatchingPipelineInput) => BatchingPipeline;
|
|
18
|
+
}
|
|
19
|
+
export declare const createWinstonTransportInternal: (options: LogscopeWinstonTransportOptions, dependencies: WinstonTransportDependencies) => TransportStream;
|
|
20
|
+
export declare const createWinstonTransport: (options: LogscopeWinstonTransportOptions) => TransportStream;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createWinstonTransport = exports.createWinstonTransportInternal = void 0;
|
|
7
|
+
const winston_transport_1 = __importDefault(require("winston-transport"));
|
|
8
|
+
const config_guards_1 = require("../config/config-guards");
|
|
9
|
+
const pipeline_1 = require("../pipeline/pipeline");
|
|
10
|
+
const pipeline_ingress_1 = require("../pipeline/pipeline-ingress");
|
|
11
|
+
const send_ingestion_request_1 = require("../transport/send-ingestion-request");
|
|
12
|
+
const map_winston_level_1 = require("./map-winston-level");
|
|
13
|
+
const UNAUTHORIZED_WARNING_MESSAGE = '[logscope] Winston transport received unauthorized response (401). Check SDK API key configuration.';
|
|
14
|
+
const RETRY_EXHAUSTED_WARNING_MESSAGE = '[logscope] Winston transport dropped log batch after max retry attempts.';
|
|
15
|
+
const LEVEL_SYMBOL = Symbol.for('level');
|
|
16
|
+
const runSafe = (callback) => {
|
|
17
|
+
try {
|
|
18
|
+
callback();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Never throw into user code.
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const runSafeWarn = (warn, message) => {
|
|
25
|
+
runSafe(() => {
|
|
26
|
+
warn(message);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const createNoopPipeline = () => {
|
|
30
|
+
return {
|
|
31
|
+
enqueue: () => { },
|
|
32
|
+
flushNow: async () => { },
|
|
33
|
+
stop: async () => { },
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const createDefaultDependencies = () => {
|
|
37
|
+
return {
|
|
38
|
+
sendBatch: (input) => (0, send_ingestion_request_1.sendIngestionRequest)(input),
|
|
39
|
+
warn: (message) => console.warn(message),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const isWinstonInfo = (value) => {
|
|
43
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
44
|
+
};
|
|
45
|
+
const toLogMessage = (info) => {
|
|
46
|
+
if (typeof info.message === 'string') {
|
|
47
|
+
return info.message;
|
|
48
|
+
}
|
|
49
|
+
if (info.message === undefined) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return JSON.stringify(info.message) ?? '';
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
try {
|
|
57
|
+
return String(info.message);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return '[Unserializable message]';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const toTimestamp = (info) => {
|
|
65
|
+
const value = info.timestamp;
|
|
66
|
+
if (value instanceof Date || typeof value === 'string' || typeof value === 'number') {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
};
|
|
71
|
+
const toMetadata = (info) => {
|
|
72
|
+
const metadataEntries = Object.entries(info).filter(([key]) => {
|
|
73
|
+
return key !== 'level' && key !== 'message' && key !== 'timestamp';
|
|
74
|
+
});
|
|
75
|
+
if (metadataEntries.length === 0) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return Object.fromEntries(metadataEntries);
|
|
79
|
+
};
|
|
80
|
+
class LogscopeWinstonTransportStream extends winston_transport_1.default {
|
|
81
|
+
ingress;
|
|
82
|
+
pipeline;
|
|
83
|
+
stopPromise = null;
|
|
84
|
+
constructor(options, dependencies) {
|
|
85
|
+
super();
|
|
86
|
+
const guardedOptions = (0, config_guards_1.guardWinstonTransportOptions)(options);
|
|
87
|
+
let hasWarnedUnauthorized = false;
|
|
88
|
+
let hasWarnedRetryExhausted = false;
|
|
89
|
+
if (!guardedOptions.isValid) {
|
|
90
|
+
runSafeWarn(dependencies.warn, (0, config_guards_1.buildInvalidWinstonOptionsWarning)(guardedOptions.invalidFields));
|
|
91
|
+
}
|
|
92
|
+
const createPipeline = dependencies.createPipeline ?? pipeline_1.createBatchingPipeline;
|
|
93
|
+
this.pipeline = (() => {
|
|
94
|
+
if (!guardedOptions.isValid) {
|
|
95
|
+
return createNoopPipeline();
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
return createPipeline({
|
|
99
|
+
endpoint: guardedOptions.endpoint,
|
|
100
|
+
apiKey: guardedOptions.apiKey,
|
|
101
|
+
sendBatch: dependencies.sendBatch,
|
|
102
|
+
flushIntervalMs: guardedOptions.flushIntervalMs,
|
|
103
|
+
retryPolicy: guardedOptions.retryPolicy,
|
|
104
|
+
onBatchResult: (result) => {
|
|
105
|
+
if (!result.shouldWarnUnauthorized || hasWarnedUnauthorized) {
|
|
106
|
+
if (result.errorKind !== 'max_retries_exceeded' || hasWarnedRetryExhausted) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
hasWarnedRetryExhausted = true;
|
|
110
|
+
runSafeWarn(dependencies.warn, RETRY_EXHAUSTED_WARNING_MESSAGE);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
hasWarnedUnauthorized = true;
|
|
114
|
+
runSafeWarn(dependencies.warn, UNAUTHORIZED_WARNING_MESSAGE);
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return createNoopPipeline();
|
|
120
|
+
}
|
|
121
|
+
})();
|
|
122
|
+
this.ingress = (0, pipeline_ingress_1.createPipelineIngress)({
|
|
123
|
+
source: guardedOptions.source,
|
|
124
|
+
logFilter: guardedOptions.logFilter,
|
|
125
|
+
pipeline: this.pipeline,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
log(info, callback) {
|
|
129
|
+
setImmediate(() => {
|
|
130
|
+
this.emit('logged', info);
|
|
131
|
+
});
|
|
132
|
+
runSafe(() => {
|
|
133
|
+
if (!isWinstonInfo(info)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const level = (0, map_winston_level_1.mapWinstonLevel)(info.level ?? info[LEVEL_SYMBOL]);
|
|
137
|
+
if (level === undefined) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.ingress.dispatch({
|
|
141
|
+
level,
|
|
142
|
+
message: toLogMessage(info),
|
|
143
|
+
metadata: toMetadata(info),
|
|
144
|
+
timestamp: toTimestamp(info),
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
callback();
|
|
148
|
+
}
|
|
149
|
+
close() {
|
|
150
|
+
void this.stopPipeline();
|
|
151
|
+
}
|
|
152
|
+
_final(callback) {
|
|
153
|
+
void this.stopPipeline().finally(() => {
|
|
154
|
+
callback();
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
stopPipeline() {
|
|
158
|
+
if (this.stopPromise !== null) {
|
|
159
|
+
return this.stopPromise;
|
|
160
|
+
}
|
|
161
|
+
this.stopPromise = this.pipeline.stop();
|
|
162
|
+
return this.stopPromise;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const createWinstonTransportInternal = (options, dependencies) => {
|
|
166
|
+
return new LogscopeWinstonTransportStream(options, dependencies);
|
|
167
|
+
};
|
|
168
|
+
exports.createWinstonTransportInternal = createWinstonTransportInternal;
|
|
169
|
+
const createWinstonTransport = (options) => {
|
|
170
|
+
return (0, exports.createWinstonTransportInternal)(options, createDefaultDependencies());
|
|
171
|
+
};
|
|
172
|
+
exports.createWinstonTransport = createWinstonTransport;
|
|
173
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/winston/transport.ts"],"names":[],"mappings":";;;;;;AAAA,0EAAgD;AAChD,2DAGiC;AAEjC,mDAI8B;AAC9B,mEAAqE;AACrE,gFAA2E;AAM3E,2DAAsD;AAEtD,MAAM,4BAA4B,GAChC,qGAAqG,CAAC;AACxG,MAAM,+BAA+B,GACnC,0EAA0E,CAAC;AAC7E,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAmBzC,MAAM,OAAO,GAAG,CAAC,QAAoB,EAAQ,EAAE;IAC7C,IAAI,CAAC;QACH,QAAQ,EAAE,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,8BAA8B;IAChC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAA+B,EAAE,OAAe,EAAQ,EAAE;IAC7E,OAA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O,EAAE,YAAY,CAAC,CAAC;AACnE,CAAC,CAAC;AALW,QAAA,8BAA8B,kCAKzC;AAEK,MAAM,sBAAsB,GAAG,CACpC,OAAwC,EACvB,EAAE;IACnB,OAAO,IAAA,sCAA8B,EAAC,OAAO,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createWinstonTransport, createWinstonTransportInternal, type LogscopeWinstonTransportOptions, type WinstonTransportDependencies, } from './winston/transport';
|
|
2
|
+
export { mapWinstonLevel } from './winston/map-winston-level';
|
|
3
|
+
import { createWinstonTransport } from './winston/transport';
|
|
4
|
+
export default createWinstonTransport;
|
package/dist/winston.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapWinstonLevel = exports.createWinstonTransportInternal = exports.createWinstonTransport = void 0;
|
|
4
|
+
var transport_1 = require("./winston/transport");
|
|
5
|
+
Object.defineProperty(exports, "createWinstonTransport", { enumerable: true, get: function () { return transport_1.createWinstonTransport; } });
|
|
6
|
+
Object.defineProperty(exports, "createWinstonTransportInternal", { enumerable: true, get: function () { return transport_1.createWinstonTransportInternal; } });
|
|
7
|
+
var map_winston_level_1 = require("./winston/map-winston-level");
|
|
8
|
+
Object.defineProperty(exports, "mapWinstonLevel", { enumerable: true, get: function () { return map_winston_level_1.mapWinstonLevel; } });
|
|
9
|
+
const transport_2 = require("./winston/transport");
|
|
10
|
+
exports.default = transport_2.createWinstonTransport;
|
|
11
|
+
//# sourceMappingURL=winston.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"winston.js","sourceRoot":"","sources":["../src/winston.ts"],"names":[],"mappings":";;;AAAA,iDAK6B;AAJ3B,mHAAA,sBAAsB,OAAA;AACtB,2HAAA,8BAA8B,OAAA;AAIhC,iEAA8D;AAArD,oHAAA,eAAe,OAAA;AAExB,mDAA6D;AAE7D,kBAAe,kCAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logscopeai/logscope",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
|
+
"description": "Supported-beta Node.js SDK for sending application logs to the Logscope ingestion API.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"types": "./dist/pino.d.ts",
|
|
14
14
|
"default": "./dist/pino.js"
|
|
15
15
|
},
|
|
16
|
+
"./winston": {
|
|
17
|
+
"types": "./dist/winston.d.ts",
|
|
18
|
+
"default": "./dist/winston.js"
|
|
19
|
+
},
|
|
16
20
|
"./package.json": "./package.json"
|
|
17
21
|
},
|
|
18
22
|
"files": [
|
|
@@ -45,13 +49,17 @@
|
|
|
45
49
|
"url": "https://github.com/logscopeai/logscope/issues"
|
|
46
50
|
},
|
|
47
51
|
"homepage": "https://github.com/logscopeai/logscope#readme",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"winston-transport": "^4.9.0"
|
|
54
|
+
},
|
|
48
55
|
"devDependencies": {
|
|
49
56
|
"@types/node": "^22.10.2",
|
|
50
57
|
"@vitest/coverage-v8": "^2.1.8",
|
|
51
58
|
"lint-staged": "^15.4.3",
|
|
52
59
|
"prettier": "^3.4.2",
|
|
53
60
|
"typescript": "^5.7.2",
|
|
54
|
-
"vitest": "^2.1.8"
|
|
61
|
+
"vitest": "^2.1.8",
|
|
62
|
+
"winston": "^3.19.0"
|
|
55
63
|
},
|
|
56
64
|
"lint-staged": {
|
|
57
65
|
"*.{ts,js,tsx,jsx,html,css,scss,json,md}": "npx prettier --config .prettierrc --write"
|