New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@tinyhttp/logger

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/logger

simple HTTP logger for tinyhttp

Source
npmnpm
Version
1.3.0
Version published
Weekly downloads
54K
-27.05%
Maintainers
1
Weekly downloads
 
Created
Source

@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

  • methods - a list of HTTP methods to log. Defaults to http's METHODS
  • timestamp.format - timestamp format. Gets consumed by dayjs library. If a string specified, used as a format, otherwise just enables it.
  • output.callback - function that recieves the log generated by the logger.
  • output.color - property that determines if the logger will generate a message with color. usefull for logging into the console, disable it if logging into file / http / etc...
  • emoji - enable emojis for HTTP status code. See http-status-emojis for a full list
  • ip - log IP address

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

  • Pino - super fast, all natural json logger.
  • Zoya - Truly highly composable logging utility.
  • Morgan - HTTP request logger middleware for node.js
  • concurrency-logger - Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request
  • Volleyball - Tiny HTTP logger for Express showing asynchronous requests and responses

Keywords

tinyhttp

FAQs

Package last updated on 26 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts