From 15ebddaec8e139307a76eb15e5e9382f40041ef6 Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 27 Oct 2022 11:33:06 -0400 Subject: [PATCH] chore(endpoint): add spacing to debug output (#4108) * chore(endpoint): add spacing to debug output * fix(logging): check for existence of log method --- packages/util-endpoints/src/debug/toDebugString.ts | 12 ++++++------ packages/util-endpoints/src/resolveEndpoint.ts | 4 ++-- .../util-endpoints/src/utils/evaluateCondition.ts | 2 +- .../util-endpoints/src/utils/evaluateConditions.ts | 2 +- .../util-endpoints/src/utils/evaluateEndpointRule.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/util-endpoints/src/debug/toDebugString.ts b/packages/util-endpoints/src/debug/toDebugString.ts index abb6d659ebfb0..9e49ca631680b 100644 --- a/packages/util-endpoints/src/debug/toDebugString.ts +++ b/packages/util-endpoints/src/debug/toDebugString.ts @@ -10,17 +10,17 @@ export function toDebugString(input: FunctionObject): string; export function toDebugString(input: FunctionReturn): string; export function toDebugString(input: EndpointObject): string; export function toDebugString(input: any): string { - if (typeof input !== 'object' || input == null) { + if (typeof input !== "object" || input == null) { return input; } - if ('ref' in input) { - return `$${toDebugString(input.ref)}` + if ("ref" in input) { + return `$${toDebugString(input.ref)}`; } - if ('fn' in input) { - return `${input.fn}(${(input.argv || []).map(toDebugString)})`; + if ("fn" in input) { + return `${input.fn}(${(input.argv || []).map(toDebugString).join(", ")})`; } return JSON.stringify(input, null, 2); -} \ No newline at end of file +} diff --git a/packages/util-endpoints/src/resolveEndpoint.ts b/packages/util-endpoints/src/resolveEndpoint.ts index 40ac8777a3f16..19795aefddb69 100644 --- a/packages/util-endpoints/src/resolveEndpoint.ts +++ b/packages/util-endpoints/src/resolveEndpoint.ts @@ -11,7 +11,7 @@ export const resolveEndpoint = (ruleSetObject: RuleSetObject, options: EndpointR const { endpointParams, logger } = options; const { parameters, rules } = ruleSetObject; - options.logger?.debug(debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`); + options.logger?.debug?.(debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`); // @ts-ignore Type 'undefined' is not assignable to type 'string | boolean' (2322) const paramsWithDefault: [string, string | boolean][] = Object.entries(parameters) @@ -48,7 +48,7 @@ export const resolveEndpoint = (ruleSetObject: RuleSetObject, options: EndpointR } } - options.logger?.debug(debugId, `Resolved endpoint: ${toDebugString(endpoint)}`); + options.logger?.debug?.(debugId, `Resolved endpoint: ${toDebugString(endpoint)}`); return endpoint; }; diff --git a/packages/util-endpoints/src/utils/evaluateCondition.ts b/packages/util-endpoints/src/utils/evaluateCondition.ts index b66f7ab15ccf2..7f26abf0cdf01 100644 --- a/packages/util-endpoints/src/utils/evaluateCondition.ts +++ b/packages/util-endpoints/src/utils/evaluateCondition.ts @@ -8,7 +8,7 @@ export const evaluateCondition = ({ assign, ...fnArgs }: ConditionObject, option } const value = callFunction(fnArgs, options); - options.logger?.debug(debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`); + options.logger?.debug?.(debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`); return { result: value === "" ? true : !!value, diff --git a/packages/util-endpoints/src/utils/evaluateConditions.ts b/packages/util-endpoints/src/utils/evaluateConditions.ts index 80ec26f581bd2..24e34cb5e92e6 100644 --- a/packages/util-endpoints/src/utils/evaluateConditions.ts +++ b/packages/util-endpoints/src/utils/evaluateConditions.ts @@ -20,7 +20,7 @@ export const evaluateConditions = (conditions: ConditionObject[] = [], options: if (toAssign) { conditionsReferenceRecord[toAssign.name] = toAssign.value; - options.logger?.debug(debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`); + options.logger?.debug?.(debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`); } } diff --git a/packages/util-endpoints/src/utils/evaluateEndpointRule.ts b/packages/util-endpoints/src/utils/evaluateEndpointRule.ts index faf7efe503a9b..849b41ae4af6d 100644 --- a/packages/util-endpoints/src/utils/evaluateEndpointRule.ts +++ b/packages/util-endpoints/src/utils/evaluateEndpointRule.ts @@ -25,7 +25,7 @@ export const evaluateEndpointRule = ( const { url, properties, headers } = endpoint; - options.logger?.debug(debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`); + options.logger?.debug?.(debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`); return { ...(headers != undefined && {