I\'d like to see a nice log with short info about each request to my server, for use during development. I\'ve seen the documentation on http://hapijs.com/api#request-logs, but
The easiest would be to use the good module with one of the good
reporters, for example good-file. Here is an example how to use it:
var Hapi = require('hapi');
var Good = require('good');
var server = new Hapi.Server();
server.connection({ port: 8080 });
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('Hello, world!');
}
});
server.route({
method: 'GET',
path: '/{name}',
handler: function (request, reply) {
reply('Hello, ' + encodeURIComponent(request.params.name) + '!');
}
});
server.register({
register: Good,
options: {
reporters: [{
reporter: require('good-file'),
events: {
response: '*',
log: '*'
},
config: {
path: '/var/log/hapi',
rotate: 'daily'
}
}]
}
}, function (err) {
if (err) {
throw err; // something bad happened loading the plugin
}
server.start(function () {
server.log('info', 'Server running at: ' + server.info.uri);
});
});