npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@seepine/hono-logger

v0.1.1

Published

logger for hono

Readme

@seepine/hono-logger

npm version npm downloads bundle License

适用于 Hono 框架的日志中间件,基于 pino 实现,支持请求日志、请求 ID 跟踪等功能。

特性

  • 🚀 基于 pino 实现,性能优异
  • 📝 支持请求日志记录
  • 🔍 支持请求 ID 跟踪
  • ⚙️ 高度可配置
  • 🎨 开发环境下美化输出

安装

# npm
npm install @seepine/hono-logger

# yarn
yarn add @seepine/hono-logger

# pnpm
pnpm add @seepine/hono-logger

# bun
bun add @seepine/hono-logger

使用

基础用法

import { Hono } from 'hono'
import { loggerMiddleware } from '@seepine/hono-logger'

const app = new Hono()

// 使用默认配置
app.use('*', loggerMiddleware())

// 或者使用自定义配置
app.use(
  '*',
  loggerMiddleware({
    level: 'debug',
  }),
)

配置选项

export type HonoLoggerOptions = {
  // 日志级别
  level?: 'error' | 'warn' | 'info' | 'debug' | 'trace'

  // 是否在日志中记录请求 ID
  logWithRequestId?: boolean // 默认: true

  // 是否启用请求日志
  requestLogEnable?: boolean // 默认: true

  // 请求 ID 的请求头名称
  requestIdHeaderName?: string // 默认: 'X-Request-Id'

  // 响应时间的请求头名称
  responseTimeHeaderName?: string // 默认: 'X-Response-Time'

  // 自定义请求 ID 生成器
  generator?: (c: Context) => string

  // 自定义获取 IP 地址的方法
  getIpAddress?: (c: Context) => string

  // 从请求头获取 IP 地址的字段列表
  getIpFromHeaders?: string[] // 默认: ['X-Real-Ip', 'X-Forwarded-For']

  // pino 输出流
  stream?: pino.DestinationStream

  // pino-pretty 配置选项
  prettyOptions?: PrettyOptions
}

Bun 运行时获取 IP 地址示例

import { getConnInfo } from 'hono/bun'

app.use(
  '*',
  loggerMiddleware({
    getIpAddress: c => {
      const info = getConnInfo(c)
      return info.remote.address
    },
  }),
)