Skip to content

KidkArolis/express-driftwood

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

express-driftwood

A tiny piece of express middleware for logging requests using 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:

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:

{
  ignore: ['/status', /^\/status/, (url) => url.indexOf('/status') > -1]
}

About

Express middleware for logging with driftwood

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%