Closed PadminiKarthika closed 5 years ago
You must create an instance of wreck using Wreck.defaults({ events: true})
and then listen events and use server.log()
to display data form wreck.
'use strict';
const Hapi = require('hapi');
const Wreck = require('wreck');
const Url = require('url');
const init = async () => {
const server = Hapi.Server({
host: 'localhost',
port: 3000
});
server.register({
plugin: require('good'),
options: {
ops: {
interval: 1000
},
reporters: {
myConsoleReporter: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{ wreck: '*' }]
}, {
module: 'good-console'
},
'stdout']
}
}
});
const wreck = Wreck.defaults({ events: true });
wreck.events.on('request', (uri, options) => {
server.log(['wreck', 'request'], Url.format(uri));
});
wreck.events.on('response', (err, details) => {
server.log(['wreck', 'response'], Url.format(details.uri));
});
const result = await wreck.get('http://www.google.com');
};
init();
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
With wreck 10.0.0, the events are getting logged. When I upgrade to wreck 14.x.x, I see that the wreck events are not getting logged. I see wreck dependency version in good's package.json as 12.x.x Does good support wreck 14.x.x ?