https://github.com/qubitproducts/koa-driftwood
https://github.com/qubitproducts/koa-driftwood
ceh cmh implement
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/qubitproducts/koa-driftwood
- Owner: QubitProducts
- Created: 2017-10-19T10:36:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-19T10:47:24.000Z (over 8 years ago)
- Last Synced: 2025-09-25T21:48:38.951Z (8 months ago)
- Topics: ceh, cmh, implement
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# express-driftwood
A tiny piece of express middleware for logging requests using [QubitProducts/driftwood](https://github.com/QubitProducts/driftwood).
### Installation
```
npm i driftwood koa-driftwood
```
### Usage
Just call `koa-driftwood` with an instance of driftwood and mount it in your Koa app before everything else:
```js
const createLogger = require('driftwood')
const Koa = require('koa')
const router = require('koa-router')()
const koaLogger = require('koa-driftwood')
createLogger.enable({ '*': 'trace' })
const log = createLogger('my-app')
const app = new Koa()
app.use(koaLogger(log))
router.get('/', (ctx) => { res.body = 'Wooo!' })
router.get('/400', (ctx) => { ctx.status = 400; ctx.body = 'You dun goofed' })
router.get('/500', (ctx) => { ctx.status = 500; ctx.body = 'We dun goofed' })
app.use(router.routes())
app.listen(1119, () => {
log.info('my-app started!')
})
```

### Options
Options can be passed as a second argument.
### options.ignore
A string, regex, function or array of the former, to match URLs that you don't want to log:
```js
{
ignore: ['/status', /^\/status/, (url) => url.indexOf('/status') > -1]
}
```