mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Merge pull request #3011 from simianhacker/fix/error-logging
Fixing the JSON Logger
This commit is contained in:
commit
c877687589
4 changed files with 19 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -82,7 +82,6 @@ module.exports = {
|
|||
return initialization()
|
||||
.then(start)
|
||||
.catch(function (err) {
|
||||
logger.error({ err: err });
|
||||
throw err;
|
||||
})
|
||||
.nodeify(cb);
|
||||
|
|
|
@ -11,7 +11,7 @@ var levels = {
|
|||
60: 'fatal'
|
||||
};
|
||||
|
||||
function JSONStream (options) {
|
||||
function JSONStream(options) {
|
||||
options = options || {};
|
||||
Writable.call(this, options);
|
||||
}
|
||||
|
@ -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();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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);
|
||||
|
@ -7,6 +9,16 @@ if (config.kibana.kibana_elasticsearch_username && config.kibana.kibana_elastics
|
|||
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;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue