An open API service indexing awesome lists of open source software.

https://github.com/qubitproducts/express-driftwood

Express middleware for logging with driftwood
https://github.com/qubitproducts/express-driftwood

ceh implement

Last synced: about 1 year ago
JSON representation

Express middleware for logging with driftwood

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 express-driftwood
```

### Usage

Just call `express-driftwood` with an instance of driftwood and mount it in your express app before everything else:

```js
const createLogger = require('driftwood')
const expressLogger = require('./index')
const express = require('express')

createLogger.enable({ '*': 'trace' })

const log = createLogger('my-app')
const app = express()

app.use(expressLogger(log))
app.get('/', (req, res) => res.send('Wooo!'))
app.get('/400', (req, res) => res.status(400).send('You dun goofed'))
app.get('/500', (req, res) => res.status(500).send('We dun goofed'))

app.listen(1119, () => {
log.info('my-app started!')
})
```

![](http://i.imgur.com/nDfx9eX.png)

### 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]
}
```

### options.rewrite

A function that rewrites urls, e.g. to remove sensitive data:

```js
{
rewrite: (url) => url.replace('secret', '*****')
}
```