koa-visit-logger
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    koa-visit-logger

    npm version

    Development style logger middleware for koa.

    <-- 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-visit-logger

    Example

    const Koa = require('koa')
    const logger = require('koa-visit-logger')
     
    const app = new Koa()
     
    app.use(logger())

    Notes

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

    Options

    // default option
    const defaults = {
      appName: 'app',
      dailyRotateFile: {
        datePattern: 'YYYY.MM.DD.HH',
        maxSize: '100m',
        maxFiles: '15d'
      },
      domain: path.join(path.dirname(__dirname), '../logs'),
      fileName: 'app',
      handler: () => { },
      transporter: () => { }
    }

    Use Custom Transporter

    const Koa = require('koa')
    const logger = require('koa-visit-logger')
     
    const app = new Koa()
     
    app.use(logger({
      handler: data => {
        // ...
      },
      transporter: data => {
        // ...
      }
    }))

    License

    MIT License

    Install

    npm i koa-visit-logger

    DownloadsWeekly Downloads

    7

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    9.97 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar