Skip to content

npm-koa-logger #113

@mowatermelon

Description

@mowatermelon

koa-logger

官方仓库

https://github.com/koajs/logger

官方npm地址

依赖包地址

https://www.npmjs.com/package/koa-logger

image

在线运行地址

https://npm.runkit.com/koa-logger

基础介绍

Development style logger middleware for koa. Compatible with request-received.

基础安装

npm install koa-logger --save   # npm
yarn add koa-logger            # Yarn

基础使用

Recommended that you .use() this middleware near the top to "wrap" all subsequent middleware.

const logger = require('koa-logger')
const Koa = require('koa')
 
const app = new Koa()
app.use(logger((str, args) => {
  // redirect koa logger to other output pipe
  // default is process.stdout(by console.log function)
}))

or

app.use(logger({
  transporter: (str, args) => {
    // ...
  }
}))

Param str is output string with ANSI Color, and you can get pure text with other modules like strip-ansi
Param args is a array by [format, method, url, status, time, length]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions