shelving/util/logmodule

Three thin wrappers around console.log/console.error that format HTTP Request and Response objects with ANSI arrow decorators. Intended for server-side request logging in development and production.

Usage

ts
import { logRequest, logRequestResponse, logRequestError } from "shelving/util";

// Log an incoming request (arrow pointing right →).
await logRequest(request);

// Log the response alongside its originating request (arrow pointing left ←).
await logRequestResponse(response, request);

// Log an error that occurred while handling a request (failure marker).
logRequestError(error, request);

Functions

Go

logRequest()function

Log a Request to the console.

logRequest(request: Request): void
Go

logRequestResponse()function

Log a Response to a Request to the console.

logRequestResponse(response: Response, request: Request): Promise<void>
Go

logRequestError()function

Log an Error from a Request to the console.

logRequestError(reason: unknown, request: Request): void