@logscopeai/logscope 0.1.0-beta.2

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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +341 -0
  3. package/dist/client/create-logscope-client.d.ts +23 -0
  4. package/dist/client/create-logscope-client.js +112 -0
  5. package/dist/client/create-logscope-client.js.map +1 -0
  6. package/dist/client/log-methods.d.ts +3 -0
  7. package/dist/client/log-methods.js +27 -0
  8. package/dist/client/log-methods.js.map +1 -0
  9. package/dist/config/config-guards.d.ts +31 -0
  10. package/dist/config/config-guards.js +128 -0
  11. package/dist/config/config-guards.js.map +1 -0
  12. package/dist/config/runtime-config.d.ts +17 -0
  13. package/dist/config/runtime-config.js +41 -0
  14. package/dist/config/runtime-config.js.map +1 -0
  15. package/dist/console/capture-console.d.ts +16 -0
  16. package/dist/console/capture-console.js +117 -0
  17. package/dist/console/capture-console.js.map +1 -0
  18. package/dist/constants.d.ts +7 -0
  19. package/dist/constants.js +17 -0
  20. package/dist/constants.js.map +1 -0
  21. package/dist/filter/level-filter.d.ts +3 -0
  22. package/dist/filter/level-filter.js +16 -0
  23. package/dist/filter/level-filter.js.map +1 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.js +26 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/logscope.d.ts +11 -0
  28. package/dist/logscope.js +61 -0
  29. package/dist/logscope.js.map +1 -0
  30. package/dist/normalization/normalize-log.d.ts +12 -0
  31. package/dist/normalization/normalize-log.js +140 -0
  32. package/dist/normalization/normalize-log.js.map +1 -0
  33. package/dist/pino/map-pino-level.d.ts +2 -0
  34. package/dist/pino/map-pino-level.js +40 -0
  35. package/dist/pino/map-pino-level.js.map +1 -0
  36. package/dist/pino/transport.d.ts +20 -0
  37. package/dist/pino/transport.js +185 -0
  38. package/dist/pino/transport.js.map +1 -0
  39. package/dist/pino.d.ts +4 -0
  40. package/dist/pino.js +11 -0
  41. package/dist/pino.js.map +1 -0
  42. package/dist/pipeline/batch-queue.d.ts +9 -0
  43. package/dist/pipeline/batch-queue.js +29 -0
  44. package/dist/pipeline/batch-queue.js.map +1 -0
  45. package/dist/pipeline/delivery-runner.d.ts +12 -0
  46. package/dist/pipeline/delivery-runner.js +63 -0
  47. package/dist/pipeline/delivery-runner.js.map +1 -0
  48. package/dist/pipeline/flush-scheduler.d.ts +14 -0
  49. package/dist/pipeline/flush-scheduler.js +39 -0
  50. package/dist/pipeline/flush-scheduler.js.map +1 -0
  51. package/dist/pipeline/pipeline-ingress.d.ts +19 -0
  52. package/dist/pipeline/pipeline-ingress.js +37 -0
  53. package/dist/pipeline/pipeline-ingress.js.map +1 -0
  54. package/dist/pipeline/pipeline.d.ts +21 -0
  55. package/dist/pipeline/pipeline.js +109 -0
  56. package/dist/pipeline/pipeline.js.map +1 -0
  57. package/dist/retry/backoff.d.ts +2 -0
  58. package/dist/retry/backoff.js +16 -0
  59. package/dist/retry/backoff.js.map +1 -0
  60. package/dist/retry/retry-policy.d.ts +7 -0
  61. package/dist/retry/retry-policy.js +26 -0
  62. package/dist/retry/retry-policy.js.map +1 -0
  63. package/dist/transport/send-ingestion-request.d.ts +4 -0
  64. package/dist/transport/send-ingestion-request.js +75 -0
  65. package/dist/transport/send-ingestion-request.js.map +1 -0
  66. package/dist/transport/transport-types.d.ts +39 -0
  67. package/dist/transport/transport-types.js +3 -0
  68. package/dist/transport/transport-types.js.map +1 -0
  69. package/dist/types.d.ts +69 -0
  70. package/dist/types.js +3 -0
  71. package/dist/types.js.map +1 -0
  72. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Logscope
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,341 @@
1
+ # logscope
2
+
3
+ > ⚠️ **Pre-release Software**
4
+ >
5
+ > This package is experimental and must not be used in production environments.
6
+ > It is provided strictly for local testing, development, and proof-of-concept validation.
7
+ > Breaking changes may occur in any minor or patch release.
8
+
9
+ `logscope` is the official Node.js SDK for Logscope.
10
+
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
+
13
+ Logscope is currently in early development. This SDK is intended for proof-of-concept validation and is not production-ready.
14
+
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
+ ---
36
+
37
+ ## What This Package Does
38
+
39
+ - Captures logs from:
40
+ - `console.log`, `console.info`, `console.warn`, `console.error` (opt-in)
41
+ - Manual SDK logging API
42
+ - Pino (via explicit transport)
43
+
44
+ - Normalizes logs to the Logscope ingestion contract
45
+ - Applies optional client-side filtering
46
+ - Batches logs (max 50 per request)
47
+ - Sends logs asynchronously to the Logscope Ingestion API
48
+ - Never throws into user code
49
+
50
+ ---
51
+
52
+ ## What This Package Does Not Do
53
+
54
+ - Store logs
55
+ - Query logs
56
+ - Render dashboards
57
+ - Perform AI analysis
58
+ - Persist logs to disk
59
+ - Replace structured logging frameworks
60
+
61
+ ---
62
+
63
+ ## Installation
64
+
65
+ ```
66
+ npm install logscope
67
+ ```
68
+
69
+ Or during development:
70
+
71
+ ```
72
+ npm link logscope
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Basic Usage (Class API)
78
+
79
+ ```ts
80
+ import { Logscope } from 'logscope';
81
+
82
+ const logscope = new Logscope({
83
+ apiKey: process.env.LOGSCOPE_API_KEY!,
84
+ });
85
+
86
+ logscope.info('Service started');
87
+ logscope.error('Payment failed', { orderId: 123 });
88
+ ```
89
+
90
+ `new Logscope({ apiKey })` uses the production ingestion URL default:
91
+
92
+ ```text
93
+ https://ingestion.logscopeai.com
94
+ ```
95
+
96
+ For development/testing, override `ingestionBaseUrl` explicitly:
97
+
98
+ ```ts
99
+ const logscope = new Logscope({
100
+ apiKey: process.env.LOGSCOPE_API_KEY!,
101
+ ingestionBaseUrl: 'http://localhost:3000',
102
+ });
103
+ ```
104
+
105
+ Compatibility API (`createLogscopeClient`) remains available:
106
+
107
+ ```ts
108
+ import { createLogscopeClient } from 'logscope';
109
+
110
+ const logscope = createLogscopeClient({
111
+ apiKey: process.env.LOGSCOPE_API_KEY!,
112
+ captureConsole: true,
113
+ context: {
114
+ source: 'billing-api',
115
+ },
116
+ logFilter: {
117
+ levels: ['warn', 'error'],
118
+ },
119
+ runtime: {
120
+ maxBatchSize: 25,
121
+ flushIntervalMs: 1_000,
122
+ maxRetries: 5,
123
+ retryBaseDelayMs: 200,
124
+ retryMaxDelayMs: 4_000,
125
+ },
126
+ });
127
+ ```
128
+
129
+ Manual API calls (`trace`/`debug`/`info`/`warn`/`error`/`fatal`) normalize logs and enqueue them for asynchronous batching (max 50 entries per request, interval flush fallback).
130
+
131
+ ---
132
+
133
+ ## Validation and Safety Guards
134
+
135
+ Runtime guards are applied before delivery:
136
+
137
+ - Required config fields are validated:
138
+ - Client: `apiKey`
139
+ - Pino transport: `apiKey`, `endpoint`, `source`
140
+ - Invalid required config triggers a single safe warning and switches to a no-op fallback pipeline.
141
+ - Warning diagnostics never include secret values such as API keys.
142
+ - `ingestionBaseUrl` is optional in SDK client config. Missing or invalid values fallback to the production default.
143
+ - `context.source` is optional; when omitted, emitted logs use deterministic fallback source value `unknown`.
144
+ - The SDK does not expose an `environment` routing field. Tenant/environment ownership is resolved by API key scope on the ingestion side.
145
+
146
+ Normalization enforces ingestion constraints:
147
+
148
+ - `message` is deterministically truncated to `<= 2048` characters.
149
+ - `metadata` is normalized to JSON-safe content and dropped if serialized size is `> 2048` bytes.
150
+
151
+ All guard paths are fail-safe and never throw into user code.
152
+
153
+ ---
154
+
155
+ ## Public Types and Utilities
156
+
157
+ The root entrypoint also exports shared contracts and normalization utilities:
158
+
159
+ ```ts
160
+ import { Logscope, normalizeLog } from 'logscope';
161
+ import type {
162
+ IngestionLogEntry,
163
+ LogLevel,
164
+ LogscopeClient,
165
+ LogscopeConfig,
166
+ LogscopeInitConfig,
167
+ } from 'logscope';
168
+ ```
169
+
170
+ `normalizeLog` converts SDK log input into ingestion-safe entries using `{ source, level, timestamp, message, metadata? }`.
171
+
172
+ ---
173
+
174
+ ## Filtering Logs
175
+
176
+ Users may restrict which logs are sent to Logscope:
177
+
178
+ ```ts
179
+ logFilter: {
180
+ levels: ['warn', 'error'],
181
+ }
182
+ ```
183
+
184
+ If no filter is configured, all logs are sent.
185
+
186
+ If `logFilter.levels` is configured as an empty array (`[]`), all logs are filtered out.
187
+
188
+ ---
189
+
190
+ ## Runtime Delivery Configuration
191
+
192
+ Runtime batching and retry quantities are configurable through `runtime` on client config:
193
+
194
+ ```ts
195
+ runtime: {
196
+ maxBatchSize?: number; // default: 50 (bounded to ingestion contract max)
197
+ flushIntervalMs?: number; // default: 2000
198
+ maxRetries?: number; // default: 3
199
+ retryBaseDelayMs?: number; // default: 250
200
+ retryMaxDelayMs?: number; // default: 2000
201
+ }
202
+ ```
203
+
204
+ Invalid runtime quantity overrides are ignored safely and fallback to defaults without throwing.
205
+
206
+ ---
207
+
208
+ ## Console Capture
209
+
210
+ `captureConsole` is disabled by default.
211
+
212
+ When set to `true`, the SDK wraps:
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`)
218
+
219
+ Wrapped methods keep original console output and arguments, and captured entries are forwarded through the same filtering and batching pipeline used by the manual client API.
220
+
221
+ ---
222
+
223
+ ## Using Logscope with Pino
224
+
225
+ Logscope does not intercept pino automatically.
226
+
227
+ Instead, it provides an explicit transport:
228
+
229
+ ```ts
230
+ import pino from 'pino';
231
+
232
+ const logger = pino({
233
+ transport: {
234
+ targets: [
235
+ {
236
+ target: 'logscope/pino',
237
+ options: {
238
+ apiKey: process.env.LOGSCOPE_API_KEY,
239
+ endpoint: 'http://localhost:3000',
240
+ source: 'billing-api',
241
+ },
242
+ },
243
+ ],
244
+ },
245
+ });
246
+ ```
247
+
248
+ The transport maps standard pino levels (`10/20/30/40/50/60`) to Logscope levels (`trace/debug/info/warn/error/fatal`), applies `logFilter.levels` before enqueueing, and sends through the same batch/retry pipeline.
249
+
250
+ ---
251
+
252
+ ## API Contract
253
+
254
+ Logs are sent to:
255
+
256
+ ```
257
+ POST /api/logs/ingest
258
+ ```
259
+
260
+ Using header:
261
+
262
+ ```
263
+ x-api-key: <LOGSCOPE_API_KEY>
264
+ ```
265
+
266
+ The request body must follow the ingestion API contract defined in the Logscope specification.
267
+
268
+ Transport status handling is classified as:
269
+
270
+ - `202` -> success
271
+ - `400` / `413` -> drop
272
+ - `401` -> unauthorized warning path
273
+ - `429` / `500` -> retry with backoff
274
+ - retriable batches are dropped after max retries
275
+
276
+ ---
277
+
278
+ ## Status
279
+
280
+ This SDK is currently:
281
+
282
+ - POC-focused
283
+ - Under active development
284
+ - Not production-ready
285
+ - Subject to API changes
286
+
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:
306
+
307
+ ```bash
308
+ npm test
309
+ ```
310
+
311
+ Run the explicit coverage gate locally with:
312
+
313
+ ```bash
314
+ npm run test:coverage
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Additional Documentation
320
+
321
+ - Hardening and coverage matrix: `docs/hardening-and-testing.md`
322
+ - 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
+ ```
@@ -0,0 +1,23 @@
1
+ import { type DispatchConsoleLog } from '../console/capture-console';
2
+ import type { ResolvedRuntimeConfig } from '../config/runtime-config';
3
+ import { type BatchingPipeline } from '../pipeline/pipeline';
4
+ import type { IngestionRequestResult } from '../transport/transport-types';
5
+ import type { LogscopeClient, LogscopeConfig } from '../types';
6
+ interface CreatePipelineInput {
7
+ ingestionBaseUrl: string;
8
+ apiKey: string;
9
+ runtimeConfig: ResolvedRuntimeConfig;
10
+ onBatchResult: (result: IngestionRequestResult) => void;
11
+ }
12
+ type CreatePipeline = (input: CreatePipelineInput) => BatchingPipeline;
13
+ type WarnFn = (message: string) => void;
14
+ type SetupConsoleCapture = (dispatchLog: DispatchConsoleLog) => void;
15
+ interface CreateLogscopeClientDependencies {
16
+ createPipeline: CreatePipeline;
17
+ warn: WarnFn;
18
+ now: () => Date;
19
+ setupConsoleCapture?: SetupConsoleCapture;
20
+ }
21
+ export declare const createLogscopeClientInternal: (config: LogscopeConfig, dependencies: CreateLogscopeClientDependencies) => LogscopeClient;
22
+ export declare const createLogscopeClient: (config: LogscopeConfig) => LogscopeClient;
23
+ export {};
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLogscopeClient = exports.createLogscopeClientInternal = void 0;
4
+ const capture_console_1 = require("../console/capture-console");
5
+ const config_guards_1 = require("../config/config-guards");
6
+ const pipeline_1 = require("../pipeline/pipeline");
7
+ const pipeline_ingress_1 = require("../pipeline/pipeline-ingress");
8
+ const send_ingestion_request_1 = require("../transport/send-ingestion-request");
9
+ const log_methods_1 = require("./log-methods");
10
+ const UNAUTHORIZED_WARNING_MESSAGE = '[logscope] Received unauthorized response (401). Check SDK API key configuration.';
11
+ const RETRY_EXHAUSTED_WARNING_MESSAGE = '[logscope] Dropping log batch after max retry attempts.';
12
+ const createNoopPipeline = () => {
13
+ return {
14
+ enqueue: () => { },
15
+ flushNow: async () => { },
16
+ stop: async () => { },
17
+ };
18
+ };
19
+ const createDefaultDependencies = () => {
20
+ const sendBatch = (input) => (0, send_ingestion_request_1.sendIngestionRequest)(input);
21
+ return {
22
+ createPipeline: (input) => (0, pipeline_1.createBatchingPipeline)({
23
+ endpoint: input.ingestionBaseUrl,
24
+ apiKey: input.apiKey,
25
+ sendBatch,
26
+ maxBatchSize: input.runtimeConfig.maxBatchSize,
27
+ flushIntervalMs: input.runtimeConfig.flushIntervalMs,
28
+ retryPolicy: input.runtimeConfig.retryPolicy,
29
+ onBatchResult: input.onBatchResult,
30
+ }),
31
+ warn: (message) => console.warn(message),
32
+ now: () => new Date(),
33
+ setupConsoleCapture: (dispatchLog) => {
34
+ (0, capture_console_1.captureConsole)({
35
+ dispatchLog,
36
+ });
37
+ },
38
+ };
39
+ };
40
+ const runSafeWarn = (warn, message) => {
41
+ try {
42
+ warn(message);
43
+ }
44
+ catch {
45
+ // Never throw into user code.
46
+ }
47
+ };
48
+ const createLogscopeClientInternal = (config, dependencies) => {
49
+ const guardedConfig = (0, config_guards_1.guardLogscopeClientConfig)(config);
50
+ let hasWarnedUnauthorized = false;
51
+ let hasWarnedRetryExhausted = false;
52
+ if (!guardedConfig.isValid) {
53
+ runSafeWarn(dependencies.warn, (0, config_guards_1.buildInvalidClientConfigWarning)(guardedConfig.invalidFields));
54
+ }
55
+ const pipeline = (() => {
56
+ if (!guardedConfig.isValid) {
57
+ return createNoopPipeline();
58
+ }
59
+ try {
60
+ return dependencies.createPipeline({
61
+ ingestionBaseUrl: guardedConfig.ingestionBaseUrl,
62
+ apiKey: guardedConfig.apiKey,
63
+ runtimeConfig: guardedConfig.runtimeConfig,
64
+ onBatchResult: (result) => {
65
+ if (!result.shouldWarnUnauthorized || hasWarnedUnauthorized) {
66
+ if (result.errorKind !== 'max_retries_exceeded' || hasWarnedRetryExhausted) {
67
+ return;
68
+ }
69
+ hasWarnedRetryExhausted = true;
70
+ runSafeWarn(dependencies.warn, RETRY_EXHAUSTED_WARNING_MESSAGE);
71
+ return;
72
+ }
73
+ hasWarnedUnauthorized = true;
74
+ runSafeWarn(dependencies.warn, UNAUTHORIZED_WARNING_MESSAGE);
75
+ },
76
+ });
77
+ }
78
+ catch {
79
+ return createNoopPipeline();
80
+ }
81
+ })();
82
+ const ingress = (0, pipeline_ingress_1.createPipelineIngress)({
83
+ source: guardedConfig.source,
84
+ logFilter: guardedConfig.logFilter,
85
+ now: dependencies.now,
86
+ pipeline,
87
+ });
88
+ const dispatchLog = (level, message, metadata) => {
89
+ ingress.dispatch({
90
+ level,
91
+ message,
92
+ metadata,
93
+ });
94
+ };
95
+ if (guardedConfig.captureConsole === true &&
96
+ guardedConfig.isValid &&
97
+ dependencies.setupConsoleCapture !== undefined) {
98
+ try {
99
+ dependencies.setupConsoleCapture(dispatchLog);
100
+ }
101
+ catch {
102
+ // Never throw into user code.
103
+ }
104
+ }
105
+ return (0, log_methods_1.createLogMethods)(dispatchLog);
106
+ };
107
+ exports.createLogscopeClientInternal = createLogscopeClientInternal;
108
+ const createLogscopeClient = (config) => {
109
+ return (0, exports.createLogscopeClientInternal)(config, createDefaultDependencies());
110
+ };
111
+ exports.createLogscopeClient = createLogscopeClient;
112
+ //# sourceMappingURL=create-logscope-client.js.map
@@ -0,0 +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,GACnC,yDAAyD,CAAC;AAqB5D,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,GAAc,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,6CAAoB,EAAC,KAAK,CAAC,CAAC;IAEpE,OAAO;QACL,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE,CACxB,IAAA,iCAAsB,EAAC;YACrB,QAAQ,EAAE,KAAK,CAAC,gBAAgB;YAChC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,SAAS;YACT,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,YAAY;YAC9C,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe;YACpD,WAAW,EAAE,KAAK,CAAC,aAAa,C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vC;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"}
@@ -0,0 +1,3 @@
1
+ import type { LogLevel, LogscopeClient } from '../types';
2
+ export type DispatchManualLog = (level: LogLevel, message: string, metadata?: unknown) => void;
3
+ export declare const createLogMethods: (dispatchManualLog: DispatchManualLog) => LogscopeClient;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLogMethods = void 0;
4
+ const createLogMethods = (dispatchManualLog) => {
5
+ return {
6
+ trace(message, metadata) {
7
+ dispatchManualLog('trace', message, metadata);
8
+ },
9
+ debug(message, metadata) {
10
+ dispatchManualLog('debug', message, metadata);
11
+ },
12
+ info(message, metadata) {
13
+ dispatchManualLog('info', message, metadata);
14
+ },
15
+ warn(message, metadata) {
16
+ dispatchManualLog('warn', message, metadata);
17
+ },
18
+ error(message, metadata) {
19
+ dispatchManualLog('error', message, metadata);
20
+ },
21
+ fatal(message, metadata) {
22
+ dispatchManualLog('fatal', message, metadata);
23
+ },
24
+ };
25
+ };
26
+ exports.createLogMethods = createLogMethods;
27
+ //# sourceMappingURL=log-methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-methods.js","sourceRoot":"","sources":["../../src/client/log-methods.ts"],"names":[],"mappings":";;;AAIO,MAAM,gBAAgB,GAAG,CAAC,iBAAoC,EAAkB,EAAE;IACvF,OAAO;QACL,KAAK,CAAC,OAAe,EAAE,QAAkB;YACvC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;QACD,KAAK,CAAC,OAAe,EAAE,QAAkB;YACvC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,OAAe,EAAE,QAAkB;YACtC,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,OAAe,EAAE,QAAkB;YACtC,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/C,CAAC;QACD,KAAK,CAAC,OAAe,EAAE,QAAkB;YACvC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;QACD,KAAK,CAAC,OAAe,EAAE,QAAkB;YACvC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,gBAAgB,oBAqB3B"}
@@ -0,0 +1,31 @@
1
+ import type { RetryPolicy } from '../retry/retry-policy';
2
+ import { type ResolvedRuntimeConfig } from './runtime-config';
3
+ import type { LogFilterConfig } from '../types';
4
+ type ClientRequiredField = 'apiKey';
5
+ type PinoRequiredField = 'apiKey' | 'endpoint' | 'source';
6
+ interface GuardResult {
7
+ isValid: boolean;
8
+ }
9
+ export interface ClientConfigGuardResult extends GuardResult {
10
+ apiKey: string;
11
+ ingestionBaseUrl: string;
12
+ source: string;
13
+ captureConsole: boolean;
14
+ logFilter?: LogFilterConfig;
15
+ runtimeConfig: ResolvedRuntimeConfig;
16
+ invalidFields: ReadonlyArray<ClientRequiredField>;
17
+ }
18
+ export interface PinoOptionsGuardResult extends GuardResult {
19
+ apiKey: string;
20
+ endpoint: string;
21
+ source: string;
22
+ flushIntervalMs?: number;
23
+ retryPolicy?: Partial<RetryPolicy>;
24
+ logFilter?: LogFilterConfig;
25
+ invalidFields: ReadonlyArray<PinoRequiredField>;
26
+ }
27
+ export declare const buildInvalidClientConfigWarning: (invalidFields: ReadonlyArray<ClientRequiredField>) => string;
28
+ export declare const buildInvalidPinoOptionsWarning: (invalidFields: ReadonlyArray<PinoRequiredField>) => string;
29
+ export declare const guardLogscopeClientConfig: (config: unknown) => ClientConfigGuardResult;
30
+ export declare const guardPinoTransportOptions: (options: unknown) => PinoOptionsGuardResult;
31
+ export {};