unnbound-logger-sdk 2.0.10 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -229
- package/dist/index.js +9 -11
- package/package.json +20 -37
- package/dist/index.d.ts +0 -10
- package/dist/types.d.ts +0 -132
- package/dist/types.js +0 -5
- package/dist/unnbound-logger.d.ts +0 -124
- package/dist/unnbound-logger.js +0 -472
- package/dist/utils/http-status-messages.d.ts +0 -9
- package/dist/utils/http-status-messages.js +0 -55
- package/dist/utils/logger-utils.d.ts +0 -34
- package/dist/utils/logger-utils.js +0 -96
- package/dist/utils/trace-context.d.ts +0 -10
- package/dist/utils/trace-context.js +0 -23
- package/dist/utils/with-trace.d.ts +0 -7
- package/dist/utils/with-trace.js +0 -20
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traceContext = void 0;
|
|
4
|
-
const async_hooks_1 = require("async_hooks");
|
|
5
|
-
class TraceContextManager {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.storage = new async_hooks_1.AsyncLocalStorage();
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!TraceContextManager.instance) {
|
|
11
|
-
TraceContextManager.instance = new TraceContextManager();
|
|
12
|
-
}
|
|
13
|
-
return TraceContextManager.instance;
|
|
14
|
-
}
|
|
15
|
-
run(traceId, callback) {
|
|
16
|
-
return this.storage.run({ traceId }, callback);
|
|
17
|
-
}
|
|
18
|
-
getTraceId() {
|
|
19
|
-
const context = this.storage.getStore();
|
|
20
|
-
return context?.traceId;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.traceContext = TraceContextManager.getInstance();
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Higher-order function that wraps a function with trace context
|
|
3
|
-
* @param fn - Function to wrap with trace context
|
|
4
|
-
* @param traceId - Optional trace ID to use (will generate new one if not provided)
|
|
5
|
-
* @returns Wrapped function that maintains trace context
|
|
6
|
-
*/
|
|
7
|
-
export declare function withTrace<T extends (...args: any[]) => any>(fn: T, traceId?: string): T;
|
package/dist/utils/with-trace.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withTrace = withTrace;
|
|
4
|
-
/**
|
|
5
|
-
* Utility function to wrap a function with trace context
|
|
6
|
-
*/
|
|
7
|
-
const uuid_1 = require("uuid");
|
|
8
|
-
const trace_context_1 = require("./trace-context");
|
|
9
|
-
/**
|
|
10
|
-
* Higher-order function that wraps a function with trace context
|
|
11
|
-
* @param fn - Function to wrap with trace context
|
|
12
|
-
* @param traceId - Optional trace ID to use (will generate new one if not provided)
|
|
13
|
-
* @returns Wrapped function that maintains trace context
|
|
14
|
-
*/
|
|
15
|
-
function withTrace(fn, traceId) {
|
|
16
|
-
const id = traceId || (0, uuid_1.v4)();
|
|
17
|
-
return ((...args) => {
|
|
18
|
-
return trace_context_1.traceContext.run(id, () => fn(...args));
|
|
19
|
-
});
|
|
20
|
-
}
|