diff --git a/README.md b/README.md index de8d82b..89a808d 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,27 @@ Types of application are generated automatically from swagger structure via [ope To generate new types after OpenAPI structure has been changed please run ``` npx openapi-typescript ./tatrapayplus_api_sandbox.json -o ./src/paths.d.ts +``` + +# Logging + +`TBPlusLogger` is exported from the package and can be subclassed to customize log output: + +```typescript +import { TBPlusSDK, TBPlusLogger } from "@tatrabanka/tatrapayplus-node"; + +class ConsoleLogger extends TBPlusLogger { + protected writeLine(line: string): void { + console.log("[ConsoleLogger]", line); + } +} + +const logger = new ConsoleLogger(); +const sdk = new TBPlusSDK(API_KEY, API_SECRET, {}, logger); +``` + +Pass `false` to the logger constructor to disable masking of sensitive fields: + +```typescript +const logger = new TBPlusLogger(false); ``` \ No newline at end of file diff --git a/package.json b/package.json index b9c886f..358b24a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatrabanka/tatrapayplus-node", - "version": "1.0.1", + "version": "1.0.2", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index e9ed1fd..69144cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ import fs from "node:fs"; import path from "node:path"; export * from "./enums"; +export { TBPlusLogger } from "./logger"; export class TBPlusSDK { private clientId: string; diff --git a/tests/live.test.ts b/tests/live.test.ts index ab0e4de..84d60e1 100644 --- a/tests/live.test.ts +++ b/tests/live.test.ts @@ -1,8 +1,13 @@ import { describe, expect, it, vi } from "vitest"; -import { GatewayMode, TBPlusSDK, PaymentMethod, SimpleStatus } from "../src"; +import { + GatewayMode, + TBPlusSDK, + TBPlusLogger, + PaymentMethod, + SimpleStatus, +} from "../src"; import dotenv from "dotenv"; import { getAvailable } from "../src/helpers"; -import { TBPlusLogger } from "../src/logger"; dotenv.config(); @@ -17,7 +22,6 @@ describe("TBPlusSDK tests on live", () => { const sdk = new TBPlusSDK( process.env.API_KEY as string, process.env.API_SECRET as string, - "192.0.2.123", ); const { data, error } = await sdk.getPaymentMethods(); expect(error).toBeUndefined(); @@ -32,7 +36,6 @@ describe("TBPlusSDK tests on live", () => { const sdk = new TBPlusSDK( process.env.API_KEY as string, process.env.API_SECRET as string, - "192.0.2.123", {}, new TestLogger(), ); @@ -75,7 +78,6 @@ describe("TBPlusSDK tests on live", () => { const sdk = new TBPlusSDK( process.env.API_KEY as string, process.env.API_SECRET as string, - "192.0.2.123", ); const { data, error } = await sdk.createPayment( {