fix request logging by setting it up after server.connection()
This commit is contained in:
parent
9258452926
commit
c7b441f6d5
|
@ -3,7 +3,6 @@
|
|||
module.exports = function devModePlugin(kibana) {
|
||||
let _ = require('lodash');
|
||||
|
||||
let bundle = require('../../server/optimize/testBundler');
|
||||
let istanbul = require('./istanbul');
|
||||
let kibanaSrcFilter = require('./kibanaSrcFilter');
|
||||
|
||||
|
@ -12,37 +11,35 @@ module.exports = function devModePlugin(kibana) {
|
|||
const SRC = fromRoot('src');
|
||||
const UI = fromRoot('src/ui');
|
||||
|
||||
if (!kibana.config.get('env.dev')) return;
|
||||
// return new kibana.Plugin({
|
||||
// init: function (server, options) {
|
||||
// server.ext('onPreHandler', istanbul({ root: SRC, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
// server.ext('onPreHandler', istanbul({ root: UI, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
|
||||
return new kibana.Plugin({
|
||||
init: function (server, options) {
|
||||
server.ext('onPreHandler', istanbul({ root: SRC, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
server.ext('onPreHandler', istanbul({ root: UI, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
// let activeBundle = null;
|
||||
|
||||
let activeBundle = null;
|
||||
// server.route({
|
||||
// path: '/specs',
|
||||
// method: 'GET',
|
||||
// handler: function (request, reply) {
|
||||
// if (!activeBundle) {
|
||||
|
||||
server.route({
|
||||
path: '/specs',
|
||||
method: 'GET',
|
||||
handler: function (request, reply) {
|
||||
if (!activeBundle) {
|
||||
// activeBundle = bundle().finally(function () {
|
||||
// activeBundle = null;
|
||||
// });
|
||||
// }
|
||||
|
||||
activeBundle = bundle().finally(function () {
|
||||
activeBundle = null;
|
||||
});
|
||||
}
|
||||
// activeBundle.then(function (path) {
|
||||
// return reply.file(path);
|
||||
// }, reply);
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
|
||||
activeBundle.then(function (path) {
|
||||
return reply.file(path);
|
||||
}, reply);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
uiExports: {
|
||||
spyModes: [
|
||||
'plugins/devMode/visDebugSpyPanel'
|
||||
]
|
||||
}
|
||||
});
|
||||
// uiExports: {
|
||||
// spyModes: [
|
||||
// 'plugins/devMode/visDebugSpyPanel'
|
||||
// ]
|
||||
// }
|
||||
// });
|
||||
};
|
||||
|
|
|
@ -25,8 +25,8 @@ module.exports = class KbnServer extends EventEmitter {
|
|||
let config = this.server.config();
|
||||
|
||||
this.ready = _.constant(this.mixin(
|
||||
require('./logging'),
|
||||
require('./http'),
|
||||
require('./logging'),
|
||||
require('./status'), // sets this.status
|
||||
require('./plugins'), // sets this.plugins
|
||||
require('./ui'), // sets this.uiExports
|
||||
|
|
|
@ -67,7 +67,7 @@ module.exports = class TransformObjStream extends Stream.Transform {
|
|||
if (typeof event.responsePayload === 'object') {
|
||||
contentLength = stringify(event.responsePayload).length;
|
||||
} else {
|
||||
contentLength = event.responsePayload.toString().length;
|
||||
contentLength = String(event.responsePayload).length;
|
||||
}
|
||||
|
||||
data.res = {
|
||||
|
|
|
@ -28,7 +28,7 @@ let color = _.memoize(function (name) {
|
|||
});
|
||||
|
||||
let type = _.memoize(function (t) {
|
||||
return _.chain(t).pad(6).trunc(6).thru(color(t)).value();
|
||||
return color(t)(_.pad(t, 7).slice(0, 7));
|
||||
});
|
||||
|
||||
let workerType = process.env.kbnWorkerType ? `${type(process.env.kbnWorkerType)} ` : '';
|
||||
|
|
|
@ -20,6 +20,7 @@ module.exports = function (kbnServer, server, config) {
|
|||
_.defaults(events, {
|
||||
log: '*',
|
||||
ops: '*',
|
||||
request: '*',
|
||||
response: '*',
|
||||
error: '*'
|
||||
});
|
||||
|
@ -27,6 +28,7 @@ module.exports = function (kbnServer, server, config) {
|
|||
else {
|
||||
_.defaults(events, {
|
||||
log: ['info', 'warning', 'error', 'fatal'],
|
||||
request: '*',
|
||||
response: '*',
|
||||
error: '*'
|
||||
});
|
||||
|
@ -36,6 +38,8 @@ module.exports = function (kbnServer, server, config) {
|
|||
register: require('good'),
|
||||
options: {
|
||||
opsInterval: 5000,
|
||||
requestHeaders: true,
|
||||
requestPayload: true,
|
||||
reporters: [
|
||||
{
|
||||
reporter: require('./LogReporter'),
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
let promify = require('bluebird').promisify;
|
||||
let glob = promify(require('glob'));
|
||||
let write = promify(require('fs').writeFile);
|
||||
let webpack = promify(require('webpack'));
|
||||
let basename = require('path').basename;
|
||||
|
||||
let fromRoot = require('../../utils/fromRoot');
|
||||
const TEST = fromRoot('test');
|
||||
const UNIT = fromRoot('test/unit');
|
||||
const ENTRY = fromRoot('test/unit.specs.entry.js');
|
||||
const BUNDLE = fromRoot('test/unit.specs.bundle.js');
|
||||
const SPECS = fromRoot('test/unit/specs/**/*.js');
|
||||
const NODE_MODULES = fromRoot('node_modules');
|
||||
|
||||
module.exports = function () {
|
||||
return glob(SPECS, { cwd: '/' })
|
||||
.filter(function (path) {
|
||||
return basename(path)[0] !== '_';
|
||||
})
|
||||
.reduce(function (memo, path) {
|
||||
return `${memo}\nrequire('${path}');`;
|
||||
}, '')
|
||||
.then(function (contents) {
|
||||
return write(ENTRY, contents, { encoding: 'utf8' });
|
||||
})
|
||||
.then(function () {
|
||||
return webpack({
|
||||
context: TEST,
|
||||
entry: ENTRY,
|
||||
output: {
|
||||
path: TEST,
|
||||
filename: 'unit.specs.bundle.js'
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(function (stats) {
|
||||
console.log(stats.toString({ colors: true }));
|
||||
return BUNDLE;
|
||||
});
|
||||
};
|
|
@ -11,11 +11,13 @@ module.exports = function (kbnServer, server, config) {
|
|||
<head><meta http-equiv="refresh" content="1"></head>
|
||||
<body>${optimizeStatus.message}</body>
|
||||
</html>
|
||||
`);
|
||||
`).code(503);
|
||||
|
||||
case 'red':
|
||||
return this(`
|
||||
<html><body>${optimizeStatus.message}, please wait.</body></html>
|
||||
`);
|
||||
<html><body>${optimizeStatus.message}</body></html>
|
||||
`).code(500);
|
||||
|
||||
}
|
||||
|
||||
var payload = {
|
||||
|
|
Loading…
Reference in a new issue