Skip to content

Commit

Permalink
fix: add logger parameter to Configuration (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
viveknair committed May 1, 2023
1 parent b0966b3 commit 3649e7a
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions templates/node/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable */
{{>licenseInfo}}

{{! Edited by Gentrace, line 6 }}
{{! Edited by Gentrace, only next line }}
const packageJson = require("../package.json");

export interface ConfigurationParameters {
Expand All @@ -13,6 +13,12 @@ export interface ConfigurationParameters {
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
{{! Edited by Gentrace, next 5 lines }}
logger?: {
log: (message: string, context?: any) => void;
warn: (message: string, context?: any) => void;
error: (message: string | Error, context?: any) => void;
};
}

export class Configuration {
Expand Down Expand Up @@ -65,6 +71,17 @@ export class Configuration {
* @type {new () => FormData}
*/
formDataCtor?: new () => any;

{{! Edited by Gentrace, next 8 lines }}
/**
* Custom logger that clients can provide to capture logs/warnings/errors from the SDK.
*/
logger?: {
log: (message: string, context?: any) => void;
warn: (message: string, context?: any) => void;
error: (message: string | Error, context?: any) => void;
};


constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
Expand All @@ -75,7 +92,9 @@ export class Configuration {
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
{{! Edited by Gentrace, lines 79-86 }}
{{! Edited by Gentrace, next 9 lines }}
this.logger = param.logger;

if (!this.baseOptions) {
this.baseOptions = {};
}
Expand Down

0 comments on commit 3649e7a

Please sign in to comment.