koa-logline
v1.0.0
Published
Koa middleware that logs request lines to an output stream
Downloads
8
Maintainers
Readme
koa-logline
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.