Logging middleware for Oak framework
To configure the logger, first add the import for Oak-Log middleware:
import { Default as logger } from "https://deno.land/x/[email protected]/mod.ts";
now, add the logger to your application:
app.use(logger());
and Tada! You have logging working now.
timeFormat
: [string
] - Time format for logsformat
: [string
] - Format for logs (Works only whenfmt: text
)enableColors
: [boolean
] - Enable pretty colors for logsoutput
: [Deno.Writer
] - An output sink for the logsfmt
: [json
|text
] - Format of the log
Default configuration looks something like:
export const defaultConfig: LoggerConfig = {
enableColors: true,
format: "${time} | ${status} |\t ${ip} |\t${method} | ${path}\n",
timeFormat: "HH:mm:ss",
output: Deno.stdout,
fmt: "text",
};