Skip to content

Commit 15ebdda

Browse files
authored
chore(endpoint): add spacing to debug output (#4108)
* chore(endpoint): add spacing to debug output * fix(logging): check for existence of log method
1 parent d600213 commit 15ebdda

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

packages/util-endpoints/src/debug/toDebugString.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ export function toDebugString(input: FunctionObject): string;
1010
export function toDebugString(input: FunctionReturn): string;
1111
export function toDebugString(input: EndpointObject): string;
1212
export function toDebugString(input: any): string {
13-
if (typeof input !== 'object' || input == null) {
13+
if (typeof input !== "object" || input == null) {
1414
return input;
1515
}
1616

17-
if ('ref' in input) {
18-
return `$${toDebugString(input.ref)}`
17+
if ("ref" in input) {
18+
return `$${toDebugString(input.ref)}`;
1919
}
2020

21-
if ('fn' in input) {
22-
return `${input.fn}(${(input.argv || []).map(toDebugString)})`;
21+
if ("fn" in input) {
22+
return `${input.fn}(${(input.argv || []).map(toDebugString).join(", ")})`;
2323
}
2424

2525
return JSON.stringify(input, null, 2);
26-
}
26+
}

packages/util-endpoints/src/resolveEndpoint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const resolveEndpoint = (ruleSetObject: RuleSetObject, options: EndpointR
1111
const { endpointParams, logger } = options;
1212
const { parameters, rules } = ruleSetObject;
1313

14-
options.logger?.debug(debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`);
14+
options.logger?.debug?.(debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`);
1515

1616
// @ts-ignore Type 'undefined' is not assignable to type 'string | boolean' (2322)
1717
const paramsWithDefault: [string, string | boolean][] = Object.entries(parameters)
@@ -48,7 +48,7 @@ export const resolveEndpoint = (ruleSetObject: RuleSetObject, options: EndpointR
4848
}
4949
}
5050

51-
options.logger?.debug(debugId, `Resolved endpoint: ${toDebugString(endpoint)}`);
51+
options.logger?.debug?.(debugId, `Resolved endpoint: ${toDebugString(endpoint)}`);
5252

5353
return endpoint;
5454
};

packages/util-endpoints/src/utils/evaluateCondition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const evaluateCondition = ({ assign, ...fnArgs }: ConditionObject, option
88
}
99
const value = callFunction(fnArgs, options);
1010

11-
options.logger?.debug(debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`);
11+
options.logger?.debug?.(debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`);
1212

1313
return {
1414
result: value === "" ? true : !!value,

packages/util-endpoints/src/utils/evaluateConditions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const evaluateConditions = (conditions: ConditionObject[] = [], options:
2020

2121
if (toAssign) {
2222
conditionsReferenceRecord[toAssign.name] = toAssign.value;
23-
options.logger?.debug(debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
23+
options.logger?.debug?.(debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
2424
}
2525
}
2626

packages/util-endpoints/src/utils/evaluateEndpointRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const evaluateEndpointRule = (
2525

2626
const { url, properties, headers } = endpoint;
2727

28-
options.logger?.debug(debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`);
28+
options.logger?.debug?.(debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`);
2929

3030
return {
3131
...(headers != undefined && {

0 commit comments

Comments
 (0)