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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pedograph

v0.1.4

Published

Logger for koa1

Downloads

14

Readme

pedograph

koa 1.x 日志模块,提供中间件和格式化日志输出功能。暂不支持koa 2.x版本

npm

1. 用法

在项目中安装pedograph

$ npm install pedograph --save

中间件中引入

const pedo = require('pedograph');

app.use(pedo.pedograph(format));

// 在上下文中引用
this.logger.debug('some infomation!');

启动你的nodejs服务器,查看日志输出

[2017-12-27 12:03:14] [GET] [/] [localhost] [INFO]  0ms
[2017-12-27 12:03:15] [GET] [/] [localhost] [DEBUG] some infomation!
[2017-12-27 12:03:15] [GET] [/] [localhost] [INFO]  514ms

应用中引入

const logger = require('pedograph').logger;

logger.debug('some infomation!');

启动你的nodejs服务器,查看日志输出

[2017-12-27 12:10:00] [DEBUG] some infomation!

2. 配置

pedograph中间件接收一个格式参数format,由可配置项以空格分割,其中可配置项如下所示:

format默认为:':datetime :method :url :ip :response-time' 依次为:时间 方法 路由 请求IP 响应时间 日志级别自动显示

可选项如下:

:datetime

日期选项,格式为YYYY-MM-DD hh:mm:ss

:method

请求方法,格式为请求方法的大写,如:GET POST PUT

:url

请求的路由,如:/home/page

:response-time

相应时间,单位毫秒ms,请求到达时为0

:user-agent

客户端(浏览器)的UA