1.0.0 • Published 8 years ago
hapi-trails v1.0.0
hapi-trails
hapi-trails is a Hapi plugin for logging to the Papertrail service.
About
This plugin is just a wrapper around the winston-papertrail library. It's only designed to make integrating with Hapi easier.
Usage
Install hapi-trails with npm:
npm install hapi-trails --save
Register the plugin:
server.register({
register: require('hapi-trails'),
options: {
host: 'YOUR_PAPERTRAIL_HOST',
port: 9999, // your papertrail port
hostname: 'hostname' // the hostname you want to appear in the log
}
}, function (error) {
// assert there's no error
Hoek.assert(!error, error);
});
You can now log to Papertrail through server.plugins['hapi-shelf']
.
server.route({
method: 'GET',
path:'/hello/{name}',
handler: function (request, reply) {
var logger = server.plugins['hapi-trails'];
logger.info(request.params.name + ' says hello');
return reply('hello ' + request.params.name);
}
});
If you visit http://localhost:8000/hello/matt you should see a message appear in your Papertrail log.
1.0.0
8 years ago