koa-logline

1.0.0 • Public • Published

koa-logline

NPM version build status

Minimal, dependency-free logging middleware for Koa web apps.

Install

npm install --save koa-logline

API

logline(stream)

Returns an async function that plugs into a Koa middleware stack.

The stream argument is an optional stream to write request logs to. If not provided, it defaults to stdout.

Log lines are written in the Common Log Format.

Usage

Default logging to stdout:

const koa = require('koa')
const logline = require('koa-logline')
 
const app = new koa()
 
app.use(logline())
 
app.listen(3000)

Logging to syslog using the syslog2 library:

const koa = require('koa')
const logline = require('koa-logline')
const syslog = require('syslog2')
 
const app = new koa()
const log = new syslog2.create()
 
app.use(logline(log))
 
app.listen(3000)

Alternatives

This package was written for a very specific use case and may not be right for yours. If you require more configurability or flexibility, search NPM for ‘koa log’ and check out the alternatives.

License

Copyright 2018 Digivizer Pty Ltd.

This project is open source under the terms of the ISC license. See the LICENSE file included with this software distribution for more information.

/koa-logline/

    Package Sidebar

    Install

    npm i koa-logline

    Weekly Downloads

    1

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    4.02 kB

    Total Files

    6

    Last publish

    Collaborators

    • maetl