@mcma/core
Advanced tools
Comparing version 0.16.3 to 0.16.4-beta4
@@ -7,3 +7,3 @@ import { LoggerProvider } from "./logger-provider"; | ||
constructor(source: string); | ||
get(requestId?: string, tracker?: McmaTrackerProperties): Logger; | ||
get(requestId?: string, tracker?: McmaTrackerProperties): Promise<Logger>; | ||
} |
@@ -10,3 +10,3 @@ "use strict"; | ||
} | ||
get(requestId, tracker) { | ||
async get(requestId, tracker) { | ||
return new console_logger_1.ConsoleLogger(this.source, requestId, tracker); | ||
@@ -13,0 +13,0 @@ } |
import { Logger } from "./logger"; | ||
import { McmaTrackerProperties } from "../model"; | ||
export interface LoggerProvider { | ||
get(requestId?: string, tracker?: McmaTrackerProperties): Logger; | ||
get(requestId?: string, tracker?: McmaTrackerProperties): Promise<Logger>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.McmaException = void 0; | ||
const utils_1 = require("./utils"); | ||
class McmaException extends Error { | ||
@@ -33,3 +34,3 @@ message; | ||
if (includeDetails && c.context) { | ||
ret += "\nContext:\n" + JSON.stringify(c.context, null, 2); | ||
ret += "\nContext:\n" + utils_1.Utils.stringify(c.context); | ||
} | ||
@@ -36,0 +37,0 @@ c = c.cause; |
@@ -9,2 +9,3 @@ declare function isValidUrl(url: string): boolean; | ||
declare function ensureValidDateOrUndefined(maybeDate: any): Date | undefined; | ||
declare function stringify(obj: any): string; | ||
declare function checkProperty(object: any, propertyName: string, expectedType: string, required?: boolean): void; | ||
@@ -20,4 +21,5 @@ export declare const Utils: { | ||
ensureValidDateOrUndefined: typeof ensureValidDateOrUndefined; | ||
stringify: typeof stringify; | ||
checkProperty: typeof checkProperty; | ||
}; | ||
export {}; |
@@ -73,2 +73,16 @@ "use strict"; | ||
} | ||
function stringify(obj) { | ||
let cache = []; | ||
return JSON.stringify(obj, function (key, value) { | ||
if (typeof value === "object" && value !== null) { | ||
if (cache.indexOf(value) !== -1) { | ||
// Circular reference found, discard key | ||
return; | ||
} | ||
// Store value in our collection | ||
cache.push(value); | ||
} | ||
return value; | ||
}, 2); | ||
} | ||
function checkProperty(object, propertyName, expectedType, required) { | ||
@@ -113,3 +127,4 @@ const propertyValue = object[propertyName]; | ||
ensureValidDateOrUndefined, | ||
stringify, | ||
checkProperty, | ||
}; |
{ | ||
"name": "@mcma/core", | ||
"version": "0.16.3", | ||
"version": "0.16.4-beta4", | ||
"description": "Node module with type definitions and helper utils for the EBU MCMA framework", | ||
@@ -5,0 +5,0 @@ "engines": { |
55263
1415