Skip to content

Commit

Permalink
docs(jsdoc): Logger Middleware (honojs#2708)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kengo Watanabe authored and yusukebe committed May 24, 2024
1 parent 8645b64 commit f696888
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions deno_dist/middleware/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ function log(
fn(out)
}

/**
* Logger middleware for Hono.
*
* @see {@link https://hono.dev/middleware/builtin/logger}
*
* @param {PrintFunc} [fn=console.log] - Optional function for customized logging behavior.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(logger())
* app.get('/', (c) => c.text('Hello Hono!'))
* ```
*/
export const logger = (fn: PrintFunc = console.log): MiddlewareHandler => {
return async function logger(c, next) {
const { method } = c.req
Expand Down
16 changes: 16 additions & 0 deletions src/middleware/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ function log(
fn(out)
}

/**
* Logger middleware for Hono.
*
* @see {@link https://hono.dev/middleware/builtin/logger}
*
* @param {PrintFunc} [fn=console.log] - Optional function for customized logging behavior.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(logger())
* app.get('/', (c) => c.text('Hello Hono!'))
* ```
*/
export const logger = (fn: PrintFunc = console.log): MiddlewareHandler => {
return async function logger(c, next) {
const { method } = c.req
Expand Down

0 comments on commit f696888

Please sign in to comment.