Consolidating package.json adding JSON logger

This commit is contained in:
Chris Cowan 2015-01-07 13:48:58 -07:00
parent e6d17d0641
commit 134e7b225d
5 changed files with 98 additions and 55 deletions

3
.gitignore vendored
View file

@ -9,4 +9,5 @@ target
.jruby
.idea
*.iml
esvm
*.log
esvm

View file

@ -1,10 +1,54 @@
{
"name": "kibana",
"private": true,
"description": "Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elasticsearch.",
"keywords": [
"kibana",
"elasticsearch",
"logstash",
"analytics",
"visualizations",
"dashboards",
"dashboarding"
],
"private": false,
"version": "4.0.0-beta3",
"description": "Kibana 4",
"main": "Gulpfile.js",
"dependencies": {},
"main": "src/server/app.js",
"homepage": "http://www.elasticsearch.org/overview/kibana/",
"bugs": "https://github.com/elasticsearch/kibana/issues",
"license": "Apache-2.0",
"author": "Rashid Khan <rashid.khan@elasticsearch.com>",
"contributors": [
"Spencer Alger <spencer.alger@elasticsearch.com>",
"Chris Cowan <chris.cowan@elasticsearch.com>",
"Joe Fleming <joe.fleming@elasticsearch.com>",
"Lukas Olson <lukas.olson@elasticsearch.com>"
],
"scripts": {
"start": "node ./src/server/bin/kibana.js",
"test": "grunt test --use-jruby",
"server": "grunt server",
"precommit": "grunt hintStagedFiles",
"prepush": "echo"
},
"repository": {
"type": "git",
"url": "https://github.com/elasticsearch/kibana.git"
},
"dependencies": {
"body-parser": "~1.10.1",
"compression": "^1.3.0",
"cookie-parser": "~1.3.3",
"debug": "~2.1.1",
"express": "~4.10.6",
"glob": "^4.3.2",
"http-proxy": "^1.8.1",
"jade": "~1.8.2",
"js-yaml": "^3.2.5",
"less-middleware": "1.0.x",
"lodash": "^2.4.1",
"morgan": "~1.5.1",
"serve-favicon": "~2.2.0"
},
"devDependencies": {
"bluebird": "~2.0.7",
"connect": "~2.19.5",
@ -60,6 +104,5 @@
"license": "Apache 2.0",
"bugs": {
"url": "https://github.com/elasticsearch/kibana/issues"
},
"homepage": "https://www.elasticsearch.org/overview/kibana"
}
}

View file

@ -1,7 +1,7 @@
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var logger = require('./lib/logger');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var compression = require('compression');

46
src/server/lib/logger.js Normal file
View file

@ -0,0 +1,46 @@
var morgan = require('morgan');
var env = process.env.NODE_ENV || 'development';
var format = 'dev';
if (env !== 'development') {
// Content lenght needs to be a number or null
morgan.token('content-length', function (req, res) {
var contentLength = (res._headers || {})['content-length'];
return contentLength && parseInt(contentLength, 10) || 'null';
});
// Need to ensure the response time is a number or null
var responseTime = morgan['response-time'];
morgan['response-time'] = function (req, res) {
var value = responseTime(req, res);
if (value === '-') return 'null';
return value;
};
// Log level
morgan.token('level', function (req, res) {
return (res.statusCode > 399) ? 'ERROR' : 'INFO';
});
var jsonFormat = '{ ';
jsonFormat += '"@timestamp": ":date[iso]", ';
jsonFormat += '"status": :status, ';
jsonFormat += '"level": ":level", ';
jsonFormat += '"name": "kibana", ';
jsonFormat += '"request_method": ":method", ';
jsonFormat += '"request": ":url", ';
jsonFormat += '"remote_addr": ":remote-addr", ';
jsonFormat += '"remote_user": ":remote-user", ';
jsonFormat += '"http_version": ":http-version", ';
jsonFormat += '"content_length": :content-length, ';
jsonFormat += '"response_time": :response-time ';
jsonFormat += ' }';
morgan.format('json', jsonFormat);
format = 'json';
}
module.exports = function () {
return morgan(format);
};

View file

@ -1,47 +0,0 @@
{
"name": "kibana",
"description": "Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elasticsearch.",
"keywords": [
"kibana",
"elasticsearch",
"logstash",
"analytics",
"visualizations",
"dashboards",
"dashboarding"
],
"homepage": "http://www.elasticsearch.org/overview/kibana/",
"bugs": "https://github.com/elasticsearch/kibana/issues",
"license": "Apache-2.0",
"author": "Rashid Khan <rashid.khan@elasticsearch.com>",
"contributors": [
"Spencer Alger <spencer.alger@elasticsearch.com>",
"Chris Cowan <chris.cowan@elasticsearch.com>",
"Joe Fleming <joe.fleming@elasticsearch.com>",
"Lukas Olson <lukas.olson@elasticsearch.com>"
],
"version": "4.0.0-rc1",
"private": false,
"scripts": {
"start": "node ./bin/kibana.js"
},
"repository": {
"type": "git",
"url": "https://github.com/elasticsearch/kibana.git"
},
"dependencies": {
"body-parser": "~1.10.1",
"compression": "^1.3.0",
"cookie-parser": "~1.3.3",
"debug": "~2.1.1",
"express": "~4.10.6",
"glob": "^4.3.2",
"http-proxy": "^1.8.1",
"jade": "~1.8.2",
"js-yaml": "^3.2.5",
"less-middleware": "1.0.x",
"lodash": "^2.4.1",
"morgan": "~1.5.1",
"serve-favicon": "~2.2.0"
}
}