unnbound-logger-sdk 2.0.2 → 2.0.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/dist/unnbound-logger.js
CHANGED
|
@@ -343,7 +343,7 @@ class UnnboundLogger {
|
|
|
343
343
|
body: (0, logger_utils_1.safeJsonParse)(req.body),
|
|
344
344
|
},
|
|
345
345
|
};
|
|
346
|
-
this.
|
|
346
|
+
this.log(options.level || 'info', logEntry);
|
|
347
347
|
return requestId;
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
@@ -360,12 +360,9 @@ class UnnboundLogger {
|
|
|
360
360
|
// Determine log level based on status code
|
|
361
361
|
let level = options.level || this.defaultLevel;
|
|
362
362
|
if (!options.level) {
|
|
363
|
-
if (res.statusCode >=
|
|
363
|
+
if (res.statusCode >= 400) {
|
|
364
364
|
level = 'error';
|
|
365
365
|
}
|
|
366
|
-
else if (res.statusCode >= 400) {
|
|
367
|
-
level = 'warn';
|
|
368
|
-
}
|
|
369
366
|
else {
|
|
370
367
|
level = 'info';
|
|
371
368
|
}
|
|
@@ -386,7 +383,7 @@ class UnnboundLogger {
|
|
|
386
383
|
body: (0, logger_utils_1.safeJsonParse)(res.locals.body),
|
|
387
384
|
},
|
|
388
385
|
};
|
|
389
|
-
this.
|
|
386
|
+
this.log(level, logEntry);
|
|
390
387
|
}
|
|
391
388
|
/**
|
|
392
389
|
* Logs an SFTP transaction
|
|
@@ -407,7 +404,7 @@ class UnnboundLogger {
|
|
|
407
404
|
duration,
|
|
408
405
|
sftp: operation,
|
|
409
406
|
};
|
|
410
|
-
this.
|
|
407
|
+
this.log(level, logEntry);
|
|
411
408
|
}
|
|
412
409
|
/**
|
|
413
410
|
* Logs a database query transaction
|
|
@@ -428,7 +425,7 @@ class UnnboundLogger {
|
|
|
428
425
|
duration,
|
|
429
426
|
db: query,
|
|
430
427
|
};
|
|
431
|
-
this.
|
|
428
|
+
this.log(level, logEntry);
|
|
432
429
|
}
|
|
433
430
|
}
|
|
434
431
|
exports.UnnboundLogger = UnnboundLogger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unnbound-logger-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "A structured logging library with TypeScript support using Pino. Provides consistent, well-typed logging across different operational contexts with automatic trace ID propagation.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a new UUID v4
|
|
3
|
-
* @returns A UUID v4 string
|
|
4
|
-
*/
|
|
5
|
-
export declare function generateUuid(): string;
|
|
6
|
-
/**
|
|
7
|
-
* Generates the current timestamp in ISO format
|
|
8
|
-
* @returns ISO timestamp string
|
|
9
|
-
*/
|
|
10
|
-
export declare function generateTimestamp(): string;
|
|
11
|
-
/**
|
|
12
|
-
* Gets or creates a trace ID for a workflow
|
|
13
|
-
* @param workflowId - The workflow ID to get a trace ID for
|
|
14
|
-
* @returns A trace ID associated with the workflow
|
|
15
|
-
*/
|
|
16
|
-
export declare function getTraceId(workflowId: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Clears a trace ID from the map
|
|
19
|
-
* @param workflowId - The workflow ID to clear
|
|
20
|
-
*/
|
|
21
|
-
export declare function clearTraceId(workflowId: string): void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateUuid = generateUuid;
|
|
4
|
-
exports.generateTimestamp = generateTimestamp;
|
|
5
|
-
exports.getTraceId = getTraceId;
|
|
6
|
-
exports.clearTraceId = clearTraceId;
|
|
7
|
-
/**
|
|
8
|
-
* Utilities for generating unique identifiers
|
|
9
|
-
*/
|
|
10
|
-
const uuid_1 = require("uuid");
|
|
11
|
-
/**
|
|
12
|
-
* Generates a new UUID v4
|
|
13
|
-
* @returns A UUID v4 string
|
|
14
|
-
*/
|
|
15
|
-
function generateUuid() {
|
|
16
|
-
return (0, uuid_1.v4)();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generates the current timestamp in ISO format
|
|
20
|
-
* @returns ISO timestamp string
|
|
21
|
-
*/
|
|
22
|
-
function generateTimestamp() {
|
|
23
|
-
return new Date().toISOString();
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Stores trace IDs by workflow ID for consistent tracking
|
|
27
|
-
*/
|
|
28
|
-
const traceIdMap = new Map();
|
|
29
|
-
/**
|
|
30
|
-
* Gets or creates a trace ID for a workflow
|
|
31
|
-
* @param workflowId - The workflow ID to get a trace ID for
|
|
32
|
-
* @returns A trace ID associated with the workflow
|
|
33
|
-
*/
|
|
34
|
-
function getTraceId(workflowId) {
|
|
35
|
-
if (!traceIdMap.has(workflowId)) {
|
|
36
|
-
traceIdMap.set(workflowId, generateUuid());
|
|
37
|
-
}
|
|
38
|
-
return traceIdMap.get(workflowId);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Clears a trace ID from the map
|
|
42
|
-
* @param workflowId - The workflow ID to clear
|
|
43
|
-
*/
|
|
44
|
-
function clearTraceId(workflowId) {
|
|
45
|
-
traceIdMap.delete(workflowId);
|
|
46
|
-
}
|