@logscopeai/logscope 0.1.0-beta.2 → 0.1.0-beta.3
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 +44 -12
- 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,4 +1,4 @@
|
|
|
1
|
-
# logscope
|
|
1
|
+
# @logscopeai/logscope
|
|
2
2
|
|
|
3
3
|
> ⚠️ **Pre-release Software**
|
|
4
4
|
>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
> It is provided strictly for local testing, development, and proof-of-concept validation.
|
|
7
7
|
> Breaking changes may occur in any minor or patch release.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`@logscopeai/logscope` is the official Node.js SDK for Logscope.
|
|
10
10
|
|
|
11
11
|
It enables Node.js applications to capture logs, normalize them, enrich them with execution context, and send them asynchronously to the Logscope Ingestion API for downstream processing.
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Logscope is currently in early development. This SDK is intended for proof-of-co
|
|
|
16
16
|
|
|
17
17
|
## Early Development Mode
|
|
18
18
|
|
|
19
|
-
During early development phases,
|
|
19
|
+
During early development phases, `@logscopeai/logscope` is expected to be executed locally using:
|
|
20
20
|
|
|
21
21
|
```
|
|
22
22
|
npm link
|
|
@@ -27,7 +27,7 @@ This allows the SDK to be developed and tested inside a consuming service before
|
|
|
27
27
|
The intended import pattern is:
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
import { Logscope } from 'logscope';
|
|
30
|
+
import { Logscope } from '@logscopeai/logscope';
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Compatibility with `npm link` is a design requirement.
|
|
@@ -40,6 +40,7 @@ Compatibility with `npm link` is a design requirement.
|
|
|
40
40
|
- `console.log`, `console.info`, `console.warn`, `console.error` (opt-in)
|
|
41
41
|
- Manual SDK logging API
|
|
42
42
|
- Pino (via explicit transport)
|
|
43
|
+
- Winston (via explicit transport)
|
|
43
44
|
|
|
44
45
|
- Normalizes logs to the Logscope ingestion contract
|
|
45
46
|
- Applies optional client-side filtering
|
|
@@ -63,13 +64,13 @@ Compatibility with `npm link` is a design requirement.
|
|
|
63
64
|
## Installation
|
|
64
65
|
|
|
65
66
|
```
|
|
66
|
-
npm install logscope
|
|
67
|
+
npm install @logscopeai/logscope
|
|
67
68
|
```
|
|
68
69
|
|
|
69
70
|
Or during development:
|
|
70
71
|
|
|
71
72
|
```
|
|
72
|
-
npm link logscope
|
|
73
|
+
npm link @logscopeai/logscope
|
|
73
74
|
```
|
|
74
75
|
|
|
75
76
|
---
|
|
@@ -77,7 +78,7 @@ npm link logscope
|
|
|
77
78
|
## Basic Usage (Class API)
|
|
78
79
|
|
|
79
80
|
```ts
|
|
80
|
-
import { Logscope } from 'logscope';
|
|
81
|
+
import { Logscope } from '@logscopeai/logscope';
|
|
81
82
|
|
|
82
83
|
const logscope = new Logscope({
|
|
83
84
|
apiKey: process.env.LOGSCOPE_API_KEY!,
|
|
@@ -105,7 +106,7 @@ const logscope = new Logscope({
|
|
|
105
106
|
Compatibility API (`createLogscopeClient`) remains available:
|
|
106
107
|
|
|
107
108
|
```ts
|
|
108
|
-
import { createLogscopeClient } from 'logscope';
|
|
109
|
+
import { createLogscopeClient } from '@logscopeai/logscope';
|
|
109
110
|
|
|
110
111
|
const logscope = createLogscopeClient({
|
|
111
112
|
apiKey: process.env.LOGSCOPE_API_KEY!,
|
|
@@ -137,6 +138,7 @@ Runtime guards are applied before delivery:
|
|
|
137
138
|
- Required config fields are validated:
|
|
138
139
|
- Client: `apiKey`
|
|
139
140
|
- Pino transport: `apiKey`, `endpoint`, `source`
|
|
141
|
+
- Winston transport: `apiKey`, `endpoint`, `source`
|
|
140
142
|
- Invalid required config triggers a single safe warning and switches to a no-op fallback pipeline.
|
|
141
143
|
- Warning diagnostics never include secret values such as API keys.
|
|
142
144
|
- `ingestionBaseUrl` is optional in SDK client config. Missing or invalid values fallback to the production default.
|
|
@@ -157,14 +159,14 @@ All guard paths are fail-safe and never throw into user code.
|
|
|
157
159
|
The root entrypoint also exports shared contracts and normalization utilities:
|
|
158
160
|
|
|
159
161
|
```ts
|
|
160
|
-
import { Logscope, normalizeLog } from 'logscope';
|
|
162
|
+
import { Logscope, normalizeLog } from '@logscopeai/logscope';
|
|
161
163
|
import type {
|
|
162
164
|
IngestionLogEntry,
|
|
163
165
|
LogLevel,
|
|
164
166
|
LogscopeClient,
|
|
165
167
|
LogscopeConfig,
|
|
166
168
|
LogscopeInitConfig,
|
|
167
|
-
} from 'logscope';
|
|
169
|
+
} from '@logscopeai/logscope';
|
|
168
170
|
```
|
|
169
171
|
|
|
170
172
|
`normalizeLog` converts SDK log input into ingestion-safe entries using `{ source, level, timestamp, message, metadata? }`.
|
|
@@ -233,7 +235,7 @@ const logger = pino({
|
|
|
233
235
|
transport: {
|
|
234
236
|
targets: [
|
|
235
237
|
{
|
|
236
|
-
target: 'logscope/pino',
|
|
238
|
+
target: '@logscopeai/logscope/pino',
|
|
237
239
|
options: {
|
|
238
240
|
apiKey: process.env.LOGSCOPE_API_KEY,
|
|
239
241
|
endpoint: 'http://localhost:3000',
|
|
@@ -249,6 +251,36 @@ The transport maps standard pino levels (`10/20/30/40/50/60`) to Logscope levels
|
|
|
249
251
|
|
|
250
252
|
---
|
|
251
253
|
|
|
254
|
+
## Using Logscope with Winston
|
|
255
|
+
|
|
256
|
+
Logscope does not patch Winston automatically.
|
|
257
|
+
|
|
258
|
+
Instead, it provides an explicit transport:
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
import { createLogger, format } from 'winston';
|
|
262
|
+
import { createWinstonTransport } from '@logscopeai/logscope/winston';
|
|
263
|
+
|
|
264
|
+
const logger = createLogger({
|
|
265
|
+
level: 'info',
|
|
266
|
+
format: format.combine(format.timestamp()),
|
|
267
|
+
transports: [
|
|
268
|
+
createWinstonTransport({
|
|
269
|
+
apiKey: process.env.LOGSCOPE_API_KEY!,
|
|
270
|
+
endpoint: 'http://localhost:3000',
|
|
271
|
+
source: 'billing-api',
|
|
272
|
+
logFilter: {
|
|
273
|
+
levels: ['warn', 'error'],
|
|
274
|
+
},
|
|
275
|
+
}),
|
|
276
|
+
],
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The Winston transport maps default npm levels (`error/warn/info/http/verbose/debug/silly`) to Logscope levels (`error/warn/info/info/debug/debug/trace`), applies `logFilter.levels` before enqueueing, and forwards through the same batch/retry pipeline.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
252
284
|
## API Contract
|
|
253
285
|
|
|
254
286
|
Logs are sent to:
|
|
@@ -337,5 +369,5 @@ npm run build -- --watch
|
|
|
337
369
|
2. In the consuming repository:
|
|
338
370
|
|
|
339
371
|
```
|
|
340
|
-
npm link logscope
|
|
372
|
+
npm link @logscopeai/logscope
|
|
341
373
|
```
|
|
@@ -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;AA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,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QAC9C,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;QACpD,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,gCAAoB;QAChE,eAAe,EAAE,OAAO,oBAAoB,KAAK,QAAQ,CAAC,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,2DAA0G;AAE1G,mDAI8B;AAC9B,mEAAqE;AACrE,gFAA2E;AAM3E,2DAAsD;AAEtD,MAAM,4BAA4B,GAChC,qGAAqG,CAAC;AACxG,MAAM,+BAA+B,GACnC,0EAA0E,CAAC;AAC7E,MAAM,YAAY,GAA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,CAAC;YAC9B,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAEM,MAAM,8BAA8B,GAAG,CAC5C,OAAwC,EACxC,YAA0C,EACzB,EAAE;IACnB,OAAO,IAAI,8BAA8B,CAAC,OAAO,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.3",
|
|
4
|
+
"description": "`@logscopeai/logscope` is the official Node.js client SDK for Logscope.",
|
|
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"
|