1. koa-logger
Logging middleware for koa
koa-logger
Package: koa-logger
Created by: koajs
Last modified: Sun, 19 Jun 2022 09:20:02 GMT
Version: 3.2.1
License: MIT
Downloads: 695,142
Repository: https://github.com/koajs/logger

Install

npm install koa-logger
yarn add koa-logger

koa-logger

npm version
build status

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

Notice: koa-logger@2 supports koa@2; if you want to use this module with koa@1, please use koa-logger@1.

<-- GET /
--> GET / 200 835ms 746b
<-- GET /
--> GET / 200 960ms 1.9kb
<-- GET /users
--> GET /users 200 357ms 922b
<-- GET /users?page=2
--> GET /users?page=2 200 466ms 4.66kb

Installation

 $ npm install koa-logger

Example

 const logger = require('koa-logger')
const Koa = require('koa')

const app = new Koa()
app.use(logger())

Notes

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

Use Custom Transporter

 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]

License

MIT

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin