UNPKG

cassava

Version:
45 lines (44 loc) 1.48 kB
import { Route } from "./Route"; import { RouterEvent } from "../RouterEvent"; import { RouterResponse } from "../RouterResponse"; /** * Logs all requests and responses. */ export declare class LoggingRoute implements Route { readonly options: LoggingRouteOptions; constructor(options?: LoggingRouteOptions); matches(evt: RouterEvent): boolean; handle(evt: RouterEvent): void; postProcess(evt: RouterEvent, resp: RouterResponse): void; requestToString(evt: RouterEvent): string; responseToString(resp: RouterResponse): string; queryMapToString(queryStringParameters: { [key: string]: string | string[]; } | null): string; headersToString(headers: { [key: string]: string | string[]; }, headersFilter: true | string[]): string; log(msg: string): void; } export interface LoggingRouteOptions { /** * Whether to hide the body of the request from logs. */ hideRequestBody?: boolean; /** * Whether to hide the body of the response from logs. */ hideResponseBody?: boolean; /** * Function to log requests with (defaults to console.log). */ logFunction?: (msg: string) => void; /** * `true` to log all request headers or an array of the names of headers to log. */ logRequestHeaders?: true | string[]; /** * `true` to log all response headers or an array of the names of headers to log. */ logResponseHeaders?: true | string[]; }