@tinyhttp/logger

npm (scoped) npm

Simple HTTP logger.

Install

pnpm i @tinyhttp/logger

API

import { logger } from '@tinyhttp/logger'

logger(options)

Returns the middleware to log HTTP requests.

Options

Example

import { App } from '@tinyhttp/app'
import { logger } from '@tinyhttp/logger'

new App()
  .use(
    logger({
      methods: ['GET', 'POST'],
      timestamp: { format: 'HH:mm:ss' },
      output: { callback: console.log, color: false }
    })
  )
  .get('/', (req, res) => res.send('Hello world'))
  .post('/', (req, res) => res.send('Sent POST'))
  .listen(3000)

Alternatives

Install

pnpm i @tinyhttp/logger

Version

1.3.0

Source

@tinyhttp/logger