add 'user' token to be used in morgan log format

This commit is contained in:
Moritz Schmidt 2017-09-30 15:39:44 +02:00 committed by Björn Dahlgren
parent a443c807e1
commit 908d993b93

3
app.js
View File

@ -19,7 +19,10 @@ setupBasicAuth(config, app)
app.use(bodyParser.json()) app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.urlencoded({ extended: false }))
morgan.token('user', function (req) { return req.auth ? req.auth.user : 'anon' })
app.use(morgan(config.logFormat || 'dev')) app.use(morgan(config.logFormat || 'dev'))
app.use(serveStatic(path.join(__dirname, 'public'))) app.use(serveStatic(path.join(__dirname, 'public')))
var logs = new Logs(config) var logs = new Logs(config)