Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jahabeebs committed Nov 8, 2024
1 parent 71631ea commit 4c2d2f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/automated-dispute/src/providers/protocolProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class ProtocolProvider implements IProtocolProvider {
url: request.url,
method: request.method,
headers: Array.from(request.headers.entries()),
body: await request.text(),
body: await request.clone().text(),
};

this.logger.debug(`Fetch Request`, reqObject);
Expand All @@ -267,7 +267,7 @@ export class ProtocolProvider implements IProtocolProvider {
url: response.url,
status: response.status,
headers: Array.from(response.headers.entries()),
body: await response.text(),
body: await response.clone().text(),
};

this.logger.debug(`Fetch Response`, respObject);
Expand Down
21 changes: 17 additions & 4 deletions packages/shared/src/services/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@ import { ILogger } from "../index.js";

type LogLevel = "error" | "warn" | "info" | "debug";

type LogEntry = {
timestamp: string;
level: LogLevel;
message: string;
stack?: string;
data?: Record<string, unknown>;
};

const validLogLevels: LogLevel[] = ["error", "warn", "info", "debug"];

/**
* Logger class that wraps the Winston logger.
* @class Logger
* @implements {ILogger}
*/
export class Logger implements ILogger {
private logger: WinstonLogger;
private static instance: Logger | null;
Expand All @@ -21,9 +34,9 @@ export class Logger implements ILogger {
format.errors({ stack: true }),
format((info) => {
const { timestamp, level, message, stack, ...meta } = info;
const logEntry: any = {
const logEntry: LogEntry = {
timestamp,
level,
level: this.isValidLogLevel(level) ? level : "info",
message,
};
if (stack) {
Expand Down Expand Up @@ -51,8 +64,8 @@ export class Logger implements ILogger {
return Logger.instance;
}

isValidLogLevel(level: any): level is LogLevel {
return validLogLevels.includes(level);
isValidLogLevel(level: string | undefined): level is LogLevel {
return validLogLevels.includes(level as LogLevel);
}

info(message: string, meta?: unknown) {
Expand Down

0 comments on commit 4c2d2f1

Please sign in to comment.