From b7dbfb987b6d1fe4646df4d4c7597ccacffe491a Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Fri, 1 Apr 2016 14:23:02 -0300 Subject: [PATCH 1/7] [logging] Support configuration reloads for logging. Fixes #4407. --- package.json | 2 +- src/cli/serve/serve.js | 17 +++++-- src/server/kbn_server.js | 14 ++++++ src/server/logging/configuration.js | 61 ++++++++++++++++++++++++ src/server/logging/index.js | 63 ++----------------------- src/server/logging/log_format_string.js | 1 + 6 files changed, 94 insertions(+), 64 deletions(-) create mode 100644 src/server/logging/configuration.js diff --git a/package.json b/package.json index bc312afd8524a..d60813bb1fc1c 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "d3": "3.5.6", "elasticsearch": "10.1.2", "elasticsearch-browser": "10.1.2", + "even-better": "7.0.1", "expiry-js": "0.1.7", "exports-loader": "0.6.2", "expose-loader": "0.7.0", @@ -104,7 +105,6 @@ "file-loader": "0.8.4", "font-awesome": "4.4.0", "glob-all": "3.0.1", - "good": "6.3.0", "good-squeeze": "2.1.0", "gridster": "0.5.6", "hapi": "8.8.1", diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index f0903d334f814..8d6738af36ca8 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -1,9 +1,9 @@ import _ from 'lodash'; -const { isWorker } = require('cluster'); -const { resolve } = require('path'); +import { isWorker } from 'cluster'; +import { resolve } from 'path'; +import { fromRoot } from '../../utils'; const cwd = process.cwd(); -import { fromRoot } from '../../utils'; let canCluster; try { @@ -24,7 +24,7 @@ const pathCollector = function () { const pluginDirCollector = pathCollector(); const pluginPathCollector = pathCollector(); -function initServerSettings(opts, extraCliOptions) { +function readServerSettings(opts, extraCliOptions) { const readYamlConfig = require('./read_yaml_config'); const settings = readYamlConfig(opts.config); const set = _.partial(_.set, settings); @@ -116,7 +116,8 @@ module.exports = function (program) { command .action(async function (opts) { - const settings = initServerSettings(opts, this.getUnknownOptions()); + const getCurrentSettings = () => readServerSettings(opts, this.getUnknownOptions()); + const settings = getCurrentSettings(); if (canCluster && opts.dev && !isWorker) { // stop processing the action and handoff to cluster manager @@ -141,6 +142,12 @@ module.exports = function (program) { process.exit(1); // eslint-disable-line no-process-exit } + process.on('SIGHUP', function reloadConfig() { + const settings = getCurrentSettings(); + kbnServer.server.log(['info', 'config'], 'Reloading logging configuration due to SIGHUP.'); + kbnServer.applyLoggingConfiguration(settings); + }); + return kbnServer; }); }; diff --git a/src/server/kbn_server.js b/src/server/kbn_server.js index 40c955fc1676e..69dc9f68bc4ac 100644 --- a/src/server/kbn_server.js +++ b/src/server/kbn_server.js @@ -3,6 +3,8 @@ import { constant, once, compact, flatten } from 'lodash'; import { promisify, resolve, fromNode } from 'bluebird'; import { isWorker } from 'cluster'; import { fromRoot, pkg } from '../utils'; +import Config from './config/config'; +import loggingConfiguration from './logging/configuration'; let rootDir = fromRoot('.'); @@ -104,4 +106,16 @@ module.exports = class KbnServer { } }); } + + applyLoggingConfiguration(settings) { + const config = Config.withDefaultSchema(settings); + const loggingOptions = loggingConfiguration(config); + const subset = { + ops: config.get('ops'), + logging: config.get('logging') + }; + const plain = JSON.stringify(subset, null, 2); + this.server.log(['info', 'config'], 'New logging configuration:\n' + plain); + this.server.plugins['even-better'].monitor.reconfigure(loggingOptions); + } }; diff --git a/src/server/logging/configuration.js b/src/server/logging/configuration.js new file mode 100644 index 0000000000000..03fa0d6164a9d --- /dev/null +++ b/src/server/logging/configuration.js @@ -0,0 +1,61 @@ +import _ from 'lodash'; +import logReporter from './log_reporter'; + +export default function loggingConfiguration(config) { + let events = config.get('logging.events'); + + if (config.get('logging.silent')) { + _.defaults(events, {}); + } + else if (config.get('logging.quiet')) { + _.defaults(events, { + log: ['listening', 'error', 'fatal'], + request: ['error'], + error: '*' + }); + } + else if (config.get('logging.verbose')) { + _.defaults(events, { + log: '*', + ops: '*', + request: '*', + response: '*', + error: '*' + }); + } + else { + _.defaults(events, { + log: ['info', 'warning', 'error', 'fatal'], + response: config.get('logging.json') ? '*' : '!', + request: ['info', 'warning', 'error', 'fatal'], + error: '*' + }); + } + + const options = { + opsInterval: config.get('ops.interval'), + requestHeaders: true, + requestPayload: true, + reporters: [ + { + reporter: logReporter, + config: { + json: config.get('logging.json'), + dest: config.get('logging.dest'), + // I'm adding the default here because if you add another filter + // using the commandline it will remove authorization. I want users + // to have to explicitly set --logging.filter.authorization=none to + // have it show up int he logs. + filter: _.defaults(config.get('logging.filter'), { + authorization: 'remove' + }) + }, + events: _.transform(events, function (filtered, val, key) { + // provide a string compatible way to remove events + if (val !== '!') filtered[key] = val; + }, {}) + } + ] + }; + return options; +} diff --git a/src/server/logging/index.js b/src/server/logging/index.js index 3279b1aca0aa6..8f4640aadfe03 100644 --- a/src/server/logging/index.js +++ b/src/server/logging/index.js @@ -1,68 +1,15 @@ -import _ from 'lodash'; import { fromNode } from 'bluebird'; +import evenBetter from 'even-better'; +import loggingConfiguration from './configuration'; -module.exports = function (kbnServer, server, config) { +export default function (kbnServer, server, config) { // prevent relying on kbnServer so this can be used with other hapi servers kbnServer = null; return fromNode(function (cb) { - let events = config.get('logging.events'); - - if (config.get('logging.silent')) { - _.defaults(events, {}); - } - else if (config.get('logging.quiet')) { - _.defaults(events, { - log: ['listening', 'error', 'fatal'], - request: ['error'], - error: '*' - }); - } - else if (config.get('logging.verbose')) { - _.defaults(events, { - log: '*', - ops: '*', - request: '*', - response: '*', - error: '*' - }); - } - else { - _.defaults(events, { - log: ['info', 'warning', 'error', 'fatal'], - response: config.get('logging.json') ? '*' : '!', - request: ['info', 'warning', 'error', 'fatal'], - error: '*' - }); - } - server.register({ - register: require('good'), - options: { - opsInterval: config.get('ops.interval'), - requestHeaders: true, - requestPayload: true, - reporters: [ - { - reporter: require('./log_reporter'), - config: { - json: config.get('logging.json'), - dest: config.get('logging.dest'), - // I'm adding the default here because if you add another filter - // using the commandline it will remove authorization. I want users - // to have to explicitly set --logging.filter.authorization=none to - // have it show up int he logs. - filter: _.defaults(config.get('logging.filter'), { - authorization: 'remove' - }) - }, - events: _.transform(events, function (filtered, val, key) { - // provide a string compatible way to remove events - if (val !== '!') filtered[key] = val; - }, {}) - } - ] - } + register: evenBetter, + options: loggingConfiguration(config) }, cb); }); }; diff --git a/src/server/logging/log_format_string.js b/src/server/logging/log_format_string.js index 544c15691bb9b..189738a1b4c52 100644 --- a/src/server/logging/log_format_string.js +++ b/src/server/logging/log_format_string.js @@ -19,6 +19,7 @@ let typeColors = { req: 'green', res: 'green', ops: 'cyan', + config: 'cyan', err: 'red', info: 'green', error: 'red', From 4759daa25f7c5e77e83db682fa2aac68ba56d4c9 Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Tue, 5 Apr 2016 18:26:26 -0300 Subject: [PATCH 2/7] [test] Add tests for SIGHUP logging configuration reload signal. --- .../reload_logging_config/kibana.test.yml | 4 ++ .../serve/__tests__/reload_logging_config.js | 64 +++++++++++++++++++ src/cli/serve/serve.js | 1 + 3 files changed, 69 insertions(+) create mode 100644 src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml create mode 100644 src/cli/serve/__tests__/reload_logging_config.js diff --git a/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml b/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml new file mode 100644 index 0000000000000..25fd7eb3c3491 --- /dev/null +++ b/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml @@ -0,0 +1,4 @@ +server: + port: 8274 +logging: + dest: src/cli/serve/__tests__/logs/first.log diff --git a/src/cli/serve/__tests__/reload_logging_config.js b/src/cli/serve/__tests__/reload_logging_config.js new file mode 100644 index 0000000000000..97123eb72d905 --- /dev/null +++ b/src/cli/serve/__tests__/reload_logging_config.js @@ -0,0 +1,64 @@ +import { spawn } from 'child_process'; +import { promisify } from 'bluebird'; +import { writeFile, readFile } from 'fs'; +import { relative, resolve } from 'path'; +import { safeDump } from 'js-yaml'; +import mkdirp from 'mkdirp'; +import rimraf from 'rimraf'; +import readYamlConfig from '../read_yaml_config'; +import expect from 'expect.js'; +const testConfigFile = follow(`fixtures/reload_logging_config/kibana.test.yml`); +const pwriteFile = promisify(writeFile); +const preadFile = promisify(readFile); +const mkdir = promisify(mkdirp); +const primraf = promisify(rimraf); + +function follow(file) { + return relative(process.cwd(), resolve(__dirname, file)); +} + +async function setLoggingDest(to) { + const conf = readYamlConfig(testConfigFile); + conf.logging = conf.logging || {}; + conf.logging.dest = follow(to); + const yaml = safeDump(conf); + await pwriteFile(testConfigFile, yaml); + return conf; +} + +function wait(time) { + return new Promise(resolve => setTimeout(() => resolve(), time)); +} + +describe(`Server logging configuration`, function () { + it(`should wait`, async function () { + const testLogsDirectory = follow(`logs`); + await primraf(testLogsDirectory); + await mkdir(testLogsDirectory); + + const conf = await setLoggingDest(`logs/first.log`); + const child = spawn(`./bin/kibana`, [`--config`, testConfigFile]); + + // wait for just a bit + await wait(5000); + + // reload configuration files + await setLoggingDest(`logs/second.log`); + child.kill(`SIGHUP`); + + // wait for some logs to be written + await wait(3000); + + // reset fixture + await setLoggingDest(`logs/first.log`); + + child.kill(); + + const second = await preadFile(follow(`logs/second.log`), 'utf8'); + const lines = second.split('\n'); + const [firstLine] = lines; + const index = firstLine.indexOf(`"message":"Reloaded logging configuration due to SIGHUP."`); + expect(second.length > 0).to.be.ok(); + expect(index !== -1).to.be.ok(); + }); +}); diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index 8d6738af36ca8..6c3b6ee1b9e13 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -146,6 +146,7 @@ module.exports = function (program) { const settings = getCurrentSettings(); kbnServer.server.log(['info', 'config'], 'Reloading logging configuration due to SIGHUP.'); kbnServer.applyLoggingConfiguration(settings); + kbnServer.server.log(['info', 'config'], 'Reloaded logging configuration due to SIGHUP.'); }); return kbnServer; From f09b374779d2dc9d8a9f5af6300ca3a4f42f4f49 Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Wed, 6 Apr 2016 17:56:23 -0300 Subject: [PATCH 3/7] [test/fix] Improved test case for logging configuration reloads. --- package.json | 1 + .../reload_logging_config/kibana.test.yml | 2 +- .../serve/__tests__/reload_logging_config.js | 65 ++++++++++++------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index d60813bb1fc1c..46baf5f567587 100644 --- a/package.json +++ b/package.json @@ -151,6 +151,7 @@ "chokidar": "1.4.3", "eslint": "1.10.3", "eslint-plugin-mocha": "1.1.0", + "event-stream": "3.3.2", "expect.js": "0.3.1", "faker": "1.1.0", "grunt": "0.4.5", diff --git a/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml b/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml index 25fd7eb3c3491..64d54aba77dac 100644 --- a/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml +++ b/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml @@ -1,4 +1,4 @@ server: port: 8274 logging: - dest: src/cli/serve/__tests__/logs/first.log + json: true diff --git a/src/cli/serve/__tests__/reload_logging_config.js b/src/cli/serve/__tests__/reload_logging_config.js index 97123eb72d905..de9b50ee711ff 100644 --- a/src/cli/serve/__tests__/reload_logging_config.js +++ b/src/cli/serve/__tests__/reload_logging_config.js @@ -1,14 +1,14 @@ import { spawn } from 'child_process'; import { promisify } from 'bluebird'; -import { writeFile, readFile } from 'fs'; +import { writeFileSync, readFile } from 'fs'; import { relative, resolve } from 'path'; import { safeDump } from 'js-yaml'; import mkdirp from 'mkdirp'; import rimraf from 'rimraf'; +import es from 'event-stream'; import readYamlConfig from '../read_yaml_config'; import expect from 'expect.js'; const testConfigFile = follow(`fixtures/reload_logging_config/kibana.test.yml`); -const pwriteFile = promisify(writeFile); const preadFile = promisify(readFile); const mkdir = promisify(mkdirp); const primraf = promisify(rimraf); @@ -17,12 +17,12 @@ function follow(file) { return relative(process.cwd(), resolve(__dirname, file)); } -async function setLoggingDest(to) { +function setLoggingJson(enabled) { const conf = readYamlConfig(testConfigFile); conf.logging = conf.logging || {}; - conf.logging.dest = follow(to); + conf.logging.json = enabled; const yaml = safeDump(conf); - await pwriteFile(testConfigFile, yaml); + writeFileSync(testConfigFile, yaml); return conf; } @@ -36,29 +36,48 @@ describe(`Server logging configuration`, function () { await primraf(testLogsDirectory); await mkdir(testLogsDirectory); - const conf = await setLoggingDest(`logs/first.log`); + let json = Infinity; + const conf = setLoggingJson(true); const child = spawn(`./bin/kibana`, [`--config`, testConfigFile]); - // wait for just a bit - await wait(5000); + child.stdout + .pipe(es.split()) + .pipe(es.mapSync(function (line) { + if (!line) { + return line; // ignore empty lines + } + if (json--) { + parseJsonLogLine(line); + } else { + expectPlainTextLogLine(line); + } + })); - // reload configuration files - await setLoggingDest(`logs/second.log`); - child.kill(`SIGHUP`); + function parseJsonLogLine(line) { + const data = JSON.parse(line); + const listening = data.tags.indexOf('listening') !== -1; + if (listening) { + switchToPlainTextLog(); + } + } - // wait for some logs to be written - await wait(3000); + function switchToPlainTextLog() { + json = 2; // ignore both "reloading" messages + setLoggingJson(false); + child.kill(`SIGHUP`); // reload logging config + } - // reset fixture - await setLoggingDest(`logs/first.log`); + function expectPlainTextLogLine(line) { + // cleanup + setLoggingJson(true); + child.kill(); - child.kill(); - - const second = await preadFile(follow(`logs/second.log`), 'utf8'); - const lines = second.split('\n'); - const [firstLine] = lines; - const index = firstLine.indexOf(`"message":"Reloaded logging configuration due to SIGHUP."`); - expect(second.length > 0).to.be.ok(); - expect(index !== -1).to.be.ok(); + // assert + const tags = `[\u001b[32minfo\u001b[39m][\u001b[36mconfig\u001b[39m]`; + const status = `Reloaded logging configuration due to SIGHUP.`; + const index = line.indexOf(`${tags} ${status}`); + expect(line.length > 0).to.be.ok(); + expect(index !== -1).to.be.ok(); + } }); }); From b73638bca09e0a956a0f6006ec2d71401078ca6d Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Thu, 7 Apr 2016 00:22:02 -0300 Subject: [PATCH 4/7] [test] Safeguard against possible exceptions, errors, and misbehaving child processes. --- .../serve/__tests__/reload_logging_config.js | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/cli/serve/__tests__/reload_logging_config.js b/src/cli/serve/__tests__/reload_logging_config.js index de9b50ee711ff..372521fb85f41 100644 --- a/src/cli/serve/__tests__/reload_logging_config.js +++ b/src/cli/serve/__tests__/reload_logging_config.js @@ -1,17 +1,11 @@ import { spawn } from 'child_process'; -import { promisify } from 'bluebird'; import { writeFileSync, readFile } from 'fs'; import { relative, resolve } from 'path'; import { safeDump } from 'js-yaml'; -import mkdirp from 'mkdirp'; -import rimraf from 'rimraf'; import es from 'event-stream'; import readYamlConfig from '../read_yaml_config'; import expect from 'expect.js'; const testConfigFile = follow(`fixtures/reload_logging_config/kibana.test.yml`); -const preadFile = promisify(readFile); -const mkdir = promisify(mkdirp); -const primraf = promisify(rimraf); function follow(file) { return relative(process.cwd(), resolve(__dirname, file)); @@ -26,20 +20,23 @@ function setLoggingJson(enabled) { return conf; } -function wait(time) { - return new Promise(resolve => setTimeout(() => resolve(), time)); -} - describe(`Server logging configuration`, function () { - it(`should wait`, async function () { - const testLogsDirectory = follow(`logs`); - await primraf(testLogsDirectory); - await mkdir(testLogsDirectory); - + it(`should be reloadable via SIGHUP process signaling`, function (done) { + let asserted = false; let json = Infinity; const conf = setLoggingJson(true); const child = spawn(`./bin/kibana`, [`--config`, testConfigFile]); + child.on('error', () => { + done(new Error('error in child process while attempting to reload config.')); + }); + + child.on('exit', (code) => { + expect(asserted).to.eql(true); + expect(code === null || code === 0).to.eql(true); + done(); + }); + child.stdout .pipe(es.split()) .pipe(es.mapSync(function (line) { @@ -47,7 +44,7 @@ describe(`Server logging configuration`, function () { return line; // ignore empty lines } if (json--) { - parseJsonLogLine(line); + expect(parseJsonLogLine).withArgs(line).to.not.throwError(); } else { expectPlainTextLogLine(line); } @@ -55,7 +52,7 @@ describe(`Server logging configuration`, function () { function parseJsonLogLine(line) { const data = JSON.parse(line); - const listening = data.tags.indexOf('listening') !== -1; + const listening = data.tags.indexOf(`listening`) !== -1; if (listening) { switchToPlainTextLog(); } @@ -68,16 +65,17 @@ describe(`Server logging configuration`, function () { } function expectPlainTextLogLine(line) { - // cleanup - setLoggingJson(true); - child.kill(); - // assert const tags = `[\u001b[32minfo\u001b[39m][\u001b[36mconfig\u001b[39m]`; const status = `Reloaded logging configuration due to SIGHUP.`; - const index = line.indexOf(`${tags} ${status}`); - expect(line.length > 0).to.be.ok(); - expect(index !== -1).to.be.ok(); + const expected = `${tags} ${status}`; + const actual = line.slice(-expected.length); + expect(actual).to.eql(expected); + + // cleanup + asserted = true; + setLoggingJson(true); + child.kill(); } }); }); From 7665d5a2601b81666ecdb40eedb3e0e6014e2edc Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Tue, 19 Apr 2016 17:07:14 -0300 Subject: [PATCH 5/7] [rename] Renamed plugin needs updated references. --- src/server/status/index.js | 2 +- src/server/status/metrics.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/status/index.js b/src/server/status/index.js index 5efbdf50b7566..e06d8900f9bd2 100644 --- a/src/server/status/index.js +++ b/src/server/status/index.js @@ -5,7 +5,7 @@ module.exports = function (kbnServer, server, config) { kbnServer.status = new ServerStatus(kbnServer.server); - if (server.plugins.good) { + if (server.plugins['even-better']) { kbnServer.mixin(require('./metrics')); } diff --git a/src/server/status/metrics.js b/src/server/status/metrics.js index 52b32af19bfca..7d37a712559e7 100644 --- a/src/server/status/metrics.js +++ b/src/server/status/metrics.js @@ -5,7 +5,7 @@ module.exports = function (kbnServer, server, config) { kbnServer.metrics = new Samples(12); - server.plugins.good.monitor.on('ops', function (event) { + server.plugins['even-better'].monitor.on('ops', function (event) { let now = Date.now(); let secSinceLast = (now - lastReport) / 1000; lastReport = now; From b8d6c8c8dda383f620183b30e3ba0535d56c6d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Bevacqua?= Date: Tue, 24 May 2016 15:39:17 -0300 Subject: [PATCH 6/7] [test] Bypass static asset optimizer and log errors more verbosely. --- .../reload_logging_config/kibana.test.yml | 2 ++ .../serve/__tests__/reload_logging_config.js | 23 ++++++++++++------- src/cli/serve/serve.js | 1 - 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml b/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml index 64d54aba77dac..22c5e93375c5f 100644 --- a/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml +++ b/src/cli/serve/__tests__/fixtures/reload_logging_config/kibana.test.yml @@ -2,3 +2,5 @@ server: port: 8274 logging: json: true +optimize: + enabled: false diff --git a/src/cli/serve/__tests__/reload_logging_config.js b/src/cli/serve/__tests__/reload_logging_config.js index 372521fb85f41..e53e646974f14 100644 --- a/src/cli/serve/__tests__/reload_logging_config.js +++ b/src/cli/serve/__tests__/reload_logging_config.js @@ -6,6 +6,7 @@ import es from 'event-stream'; import readYamlConfig from '../read_yaml_config'; import expect from 'expect.js'; const testConfigFile = follow(`fixtures/reload_logging_config/kibana.test.yml`); +const cli = follow(`../../../../bin/kibana`); function follow(file) { return relative(process.cwd(), resolve(__dirname, file)); @@ -25,13 +26,14 @@ describe(`Server logging configuration`, function () { let asserted = false; let json = Infinity; const conf = setLoggingJson(true); - const child = spawn(`./bin/kibana`, [`--config`, testConfigFile]); + const child = spawn(cli, [`--config`, testConfigFile]); - child.on('error', () => { - done(new Error('error in child process while attempting to reload config.')); + child.on('error', err => { + done(new Error(`error in child process while attempting to reload config. +${err.stack || err.message || err}`)); }); - child.on('exit', (code) => { + child.on('exit', code => { expect(asserted).to.eql(true); expect(code === null || code === 0).to.eql(true); done(); @@ -51,10 +53,15 @@ describe(`Server logging configuration`, function () { })); function parseJsonLogLine(line) { - const data = JSON.parse(line); - const listening = data.tags.indexOf(`listening`) !== -1; - if (listening) { - switchToPlainTextLog(); + try { + const data = JSON.parse(line); + const listening = data.tags.indexOf(`listening`) !== -1; + if (listening) { + switchToPlainTextLog(); + } + } catch (err) { + expect(`Error parsing log line as JSON\n +${err.stack || err.message || err}`).to.eql(true); } } diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index 622f32f8bd02b..9b73b11720f28 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -26,7 +26,6 @@ const pluginDirCollector = pathCollector(); const pluginPathCollector = pathCollector(); function readServerSettings(opts, extraCliOptions) { - const readYamlConfig = require('./read_yaml_config'); const settings = readYamlConfig(opts.config); const set = _.partial(_.set, settings); const get = _.partial(_.get, settings); From 59981ba9bc302dbddf95e7f11f9d3d1b0d89f2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Bevacqua?= Date: Wed, 1 Jun 2016 17:26:09 -0300 Subject: [PATCH 7/7] [dep] Bump even-better to 7.0.2 fixing potential memory leak issues. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0511f24d46519..dad26550ace42 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "d3": "3.5.6", "elasticsearch": "10.1.2", "elasticsearch-browser": "10.1.2", - "even-better": "7.0.1", + "even-better": "7.0.2", "expiry-js": "0.1.7", "exports-loader": "0.6.2", "expose-loader": "0.7.0",