Skip to Content
Senri

Logging

Log one line per request with logger(). Print the routes with showRoutes()

import { ,  } from "@senrijs/senri";

const  = ();

.(());                      // one colored line per request
// app.use(logger({ format: "json" })); // JSON in the same shape as pino
  • It prints the method, path, status and time, one line per request
  • Colors are on by default. When writing to a file or CI, set color: false
  • { format: "json" } prints JSON in the same shape as pino
  • It also prints errors thrown by handlers (c.error)
  • Register it first to include the time of the other middleware

showRoutes(app, url) prints the URL and the registered routes. serve() prints the same when it starts, so use this when you start the server with a runtime API yourself.

.("/", () => "hi");

.({ : 3927 }, .);
(, "http://localhost:3927");   // { color: false } for no colors

Options

Prop

Type

On this page