Use APL debug util

This commit is contained in:
Krzysztof Wolski 2022-09-05 11:09:06 +02:00
parent 668b96ac4c
commit 027b239114
5 changed files with 9 additions and 5 deletions

View file

@ -50,3 +50,4 @@ Use the namespace name to enable debug logs for each module.
| \app-sdk:\* | Enable all | | \app-sdk:\* | Enable all |
| app-sdk:AppBridge | Enable [AppBridge](./app-bridge.md) (browser only) | | app-sdk:AppBridge | Enable [AppBridge](./app-bridge.md) (browser only) |
| app-sdk:Middleware:\* | Enable all middlewares (node only) | | app-sdk:Middleware:\* | Enable all middlewares (node only) |
| app-sdk:APL:\* | Enable all APLs (node only) |

3
src/APL/apl-debug.ts Normal file
View file

@ -0,0 +1,3 @@
import { createDebug } from "../debug";
export const createAPLDebug = (namespace: string) => createDebug(`APL:${namespace}`);

View file

@ -1,9 +1,9 @@
import debugPkg from "debug";
import { promises as fsPromises } from "fs"; import { promises as fsPromises } from "fs";
import { APL, AuthData } from "./apl"; import { APL, AuthData } from "./apl";
import { createAPLDebug } from "./apl-debug";
const debug = debugPkg.debug("app-sdk:FileAPL"); const debug = createAPLDebug("FileAPL");
export type FileAPLConfig = { export type FileAPLConfig = {
fileName?: string; fileName?: string;

View file

@ -1,10 +1,10 @@
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
import debugPkg from "debug";
import fetch from "node-fetch"; import fetch from "node-fetch";
import { APL, AuthData } from "./apl"; import { APL, AuthData } from "./apl";
import { createAPLDebug } from "./apl-debug";
const debug = debugPkg.debug("app-sdk:VercelAPL"); const debug = createAPLDebug("VercelAPL");
export const VercelAPLVariables = { export const VercelAPLVariables = {
TOKEN_VARIABLE_NAME: "SALEOR_AUTH_TOKEN", TOKEN_VARIABLE_NAME: "SALEOR_AUTH_TOKEN",

View file

@ -5,7 +5,7 @@ import { createDebug } from "../debug";
export const createMiddlewareDebug = (middleware: string) => export const createMiddlewareDebug = (middleware: string) =>
createDebug(`Middleware:${middleware}`); createDebug(`Middleware:${middleware}`);
type DebugFactory = (handlerName: string) => (msg: string, ...args: any[]) => void; type DebugFactory = (handlerName: string) => (msg: string, ...args: unknown[]) => void;
/** /**
* Experimental. Needs to be tested and evaluated on security * Experimental. Needs to be tested and evaluated on security