@mcma/core 0.16.3 → 0.16.4-beta4
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/lib/logging/console-logger-provider.d.ts +1 -1
- package/dist/lib/logging/console-logger-provider.js +1 -1
- package/dist/lib/logging/logger-provider.d.ts +1 -1
- package/dist/lib/mcma-exception.js +2 -1
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +15 -0
- package/package.json +1 -1
|
@@ -4,5 +4,5 @@ import { McmaTrackerProperties } from "../model";
|
|
|
4
4
|
export declare class ConsoleLoggerProvider implements LoggerProvider {
|
|
5
5
|
private source;
|
|
6
6
|
constructor(source: string);
|
|
7
|
-
get(requestId?: string, tracker?: McmaTrackerProperties): Logger
|
|
7
|
+
get(requestId?: string, tracker?: McmaTrackerProperties): Promise<Logger>;
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from "./logger";
|
|
2
2
|
import { McmaTrackerProperties } from "../model";
|
|
3
3
|
export interface LoggerProvider {
|
|
4
|
-
get(requestId?: string, tracker?: McmaTrackerProperties): Logger
|
|
4
|
+
get(requestId?: string, tracker?: McmaTrackerProperties): Promise<Logger>;
|
|
5
5
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.McmaException = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
4
5
|
class McmaException extends Error {
|
|
5
6
|
message;
|
|
6
7
|
cause;
|
|
@@ -30,7 +31,7 @@ class McmaException extends Error {
|
|
|
30
31
|
ret += "Error: " + (c.message ?? c);
|
|
31
32
|
}
|
|
32
33
|
if (includeDetails && c.context) {
|
|
33
|
-
ret += "\nContext:\n" +
|
|
34
|
+
ret += "\nContext:\n" + utils_1.Utils.stringify(c.context);
|
|
34
35
|
}
|
|
35
36
|
c = c.cause;
|
|
36
37
|
if (c) {
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare function sleep(timeout: number): Promise<void>;
|
|
|
6
6
|
declare function isValidDateString(value: any): boolean;
|
|
7
7
|
declare function reviver(this: any, key: string, value: any): any;
|
|
8
8
|
declare function ensureValidDateOrUndefined(maybeDate: any): Date | undefined;
|
|
9
|
+
declare function stringify(obj: any): string;
|
|
9
10
|
declare function checkProperty(object: any, propertyName: string, expectedType: string, required?: boolean): void;
|
|
10
11
|
export declare const Utils: {
|
|
11
12
|
isValidUrl: typeof isValidUrl;
|
|
@@ -16,6 +17,7 @@ export declare const Utils: {
|
|
|
16
17
|
isValidDateString: typeof isValidDateString;
|
|
17
18
|
reviver: typeof reviver;
|
|
18
19
|
ensureValidDateOrUndefined: typeof ensureValidDateOrUndefined;
|
|
20
|
+
stringify: typeof stringify;
|
|
19
21
|
checkProperty: typeof checkProperty;
|
|
20
22
|
};
|
|
21
23
|
export {};
|
package/dist/lib/utils.js
CHANGED
|
@@ -70,6 +70,20 @@ function ensureValidDateOrUndefined(maybeDate) {
|
|
|
70
70
|
}
|
|
71
71
|
return date;
|
|
72
72
|
}
|
|
73
|
+
function stringify(obj) {
|
|
74
|
+
let cache = [];
|
|
75
|
+
return JSON.stringify(obj, function (key, value) {
|
|
76
|
+
if (typeof value === "object" && value !== null) {
|
|
77
|
+
if (cache.indexOf(value) !== -1) {
|
|
78
|
+
// Circular reference found, discard key
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// Store value in our collection
|
|
82
|
+
cache.push(value);
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}, 2);
|
|
86
|
+
}
|
|
73
87
|
function checkProperty(object, propertyName, expectedType, required) {
|
|
74
88
|
const propertyValue = object[propertyName];
|
|
75
89
|
const propertyType = typeof propertyValue;
|
|
@@ -109,5 +123,6 @@ exports.Utils = {
|
|
|
109
123
|
isValidDateString,
|
|
110
124
|
reviver,
|
|
111
125
|
ensureValidDateOrUndefined,
|
|
126
|
+
stringify,
|
|
112
127
|
checkProperty,
|
|
113
128
|
};
|