Skip to content

Commit f86e518

Browse files
committed
chore(logObj): allow optional depth arg to override default: 4
1 parent 2d62307 commit f86e518

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/createYahooFinance.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class YahooFinance {
1212
fetch: typeof fetch;
1313
fetchDevel?: () => Promise<typeof fetch>;
1414
};
15-
_logObj: (obj: unknown) => void;
15+
_logObj: (obj: unknown, opts?: { depth?: number }) => void;
1616

1717
constructor(options?: YahooFinanceOptions) {
1818
/// XXX TODO mergeoptions from setGlobalConfig
@@ -60,7 +60,8 @@ class YahooFinance {
6060
// @ts-ignore: relevant for ts-json-schema-generator
6161
this._logObj = Deno.stdout.isTerminal()
6262
// deno-lint-ignore no-explicit-any
63-
? (obj: any) => this._opts.logger!.dir(obj, { depth: 4, colors: true })
63+
? (obj: any, opts?: { depth?: number }) =>
64+
this._opts.logger!.dir(obj, { depth: opts?.depth ?? 4, colors: true })
6465
// deno-lint-ignore no-explicit-any
6566
: (obj: any) => this._opts.logger!.info(JSON.stringify(obj, null, 2));
6667
}

src/lib/validate/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type ValidationError = {
2121
export type ValidationCtx = {
2222
definitions: JSONSchema["definitions"];
2323
logger: Logger;
24-
logObj: (obj: unknown) => void;
24+
logObj: (obj: unknown, opts?: { depth?: number }) => void;
2525
};
2626

2727
export type Validator = (

src/lib/validateAndCoerceTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ValidateParams {
3232
schemaKey: string;
3333
options: ValidationOptions;
3434
logger: Logger;
35-
logObj: (obj: unknown) => void;
35+
logObj: (obj: unknown, opts?: { depth?: number }) => void;
3636
}
3737

3838
const doneAlready = new Map();
@@ -241,7 +241,7 @@ function validate({
241241
logger.info(
242242
"The following result did not validate with schema: " + schemaKey,
243243
);
244-
logObj(errors);
244+
logObj(errors, { depth: 5 });
245245
// logObj(object);
246246
logger.info(`
247247
This may happen intermittently and you should catch errors appropriately.

0 commit comments

Comments
 (0)