express-bunyan-logger
Advanced tools
Comparing version 0.0.3 to 0.0.4
30
index.js
@@ -14,8 +14,10 @@ var bunyan = require('bunyan'), | ||
module.exports.errorLogger = function(opts) { | ||
var logger, opts = opts || { | ||
// default format | ||
format: ":remote-address - :method :url HTTP/:http-version :status-code :content-length :referer :user-agent[family] :user-agent[major].:user-agent[minor] :user-agent[os]" | ||
}; | ||
(typeof opts.format != 'function') && (opts.format = compile(opts.format)); | ||
var logger, opts = opts || {}, format; | ||
// default format | ||
format = opts.format || ":remote-address - :method :url HTTP/:http-version :status-code :content-length :referer :user-agent[family] :user-agent[major].:user-agent[minor] :user-agent[os]"; | ||
delete opts.format; // don't pass it to bunyan | ||
(typeof format != 'function') && (format = compile(format)); | ||
return function(err, req, res, next) { | ||
@@ -28,8 +30,8 @@ function logging() { | ||
status = res.statusCode, | ||
method = req.method, | ||
url = req.url || '-', | ||
referer = req.header('referer') || '-', | ||
ua = useragent.parse(req.header('user-agent')), | ||
httpVersion = req.httpVersionMajor+'.'+req.httpVersionMinor, | ||
ip, logFn; | ||
method = req.method, | ||
url = req.url || '-', | ||
referer = req.header('referer') || '-', | ||
ua = useragent.parse(req.header('user-agent')), | ||
httpVersion = req.httpVersionMajor+'.'+req.httpVersionMinor, | ||
ip, logFn; | ||
@@ -76,3 +78,3 @@ | ||
logFn.call(logger, meta, opts.format(meta)); | ||
logFn.call(logger, meta, format(meta)); | ||
} | ||
@@ -95,4 +97,4 @@ | ||
return '"\n + ((meta["' + name + '"]) || "-") + "'; | ||
}) + '";' | ||
}) + '";'; | ||
return new Function('meta', js); | ||
}; | ||
} |
{ | ||
"name": "express-bunyan-logger", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "a bunyan logger middleware for express", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,3 +9,3 @@ var express = require('express'), | ||
var app = express(); | ||
app.use(bunyanLogger()); | ||
app.use(bunyanLogger({})); | ||
@@ -12,0 +12,0 @@ app.get('/', function(req, res) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10571