Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the JSON Logger #3011

Merged
merged 1 commit into from
Feb 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/bin/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ server.start(function (err) {
if (config.kibana.pid_file) {
return fs.writeFile(config.kibana.pid_file, process.pid, function (err) {
if (err) {
logger.fatal('Failed to write PID file to %s', config.kibana.pid_file);
logger.fatal({ err: err }, 'Failed to write PID file to %s', config.kibana.pid_file);
process.exit(1);
}
});
Expand Down
1 change: 0 additions & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ module.exports = {
return initialization()
.then(start)
.catch(function (err) {
logger.error({ err: err });
throw err;
})
.nodeify(cb);
Expand Down
7 changes: 5 additions & 2 deletions src/server/lib/JSONStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var levels = {
60: 'fatal'
};

function JSONStream (options) {
function JSONStream(options) {
options = options || {};
Writable.call(this, options);
}
Expand All @@ -31,7 +31,10 @@ JSONStream.prototype._write = function (entry, encoding, callback) {
'response': entry.res
};

if (entry.error) output.error = entry.err;
if (entry.err) {
output.error = entry.err;
if (!output.message) output.message = output.error.message;
}

process.stdout.write(JSON.stringify(output) + "\n");
callback();
Expand Down
14 changes: 13 additions & 1 deletion src/server/lib/elasticsearch_client.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
var config = require('../config');
var elasticsearch = require('elasticsearch');
var logger = require('./logger');
var _ = require('lodash');
var util = require('util');
var url = require('url');
var uri = url.parse(config.elasticsearch);
if (config.kibana.kibana_elasticsearch_username && config.kibana.kibana_elasticsearch_password) {
uri.auth = util.format('%s:%s', config.kibana.kibana_elasticsearch_username, config.kibana.kibana_elasticsearch_password);
}
module.exports = new elasticsearch.Client({
host: url.format(uri)
host: url.format(uri),
log: function (config) {
this.error = function (err) {
logger.error({ err: err });
};
this.warning = _.bindKey(logger, 'warn');
this.info = _.noop;
this.debug = _.noop;
this.trace = _.noop;
this.close = _.noop;
}
});