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
- Host: GitHub
- URL: https://github.com/qubitproducts/express-driftwood
- Owner: QubitProducts
- Created: 2016-11-02T16:26:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-10-23T12:44:11.000Z (over 6 years ago)
- Last Synced: 2025-03-23T18:18:11.779Z (about 1 year ago)
- Topics: ceh, implement
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 4
- Forks: 2
- 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 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!')
})
```

### 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', '*****')
}
```