-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.js
38 lines (34 loc) · 844 Bytes
/
logging.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var Hapi = require('hapi'),
good = require('good');
// Create a server with a host and port
var server = Hapi.createServer('127.0.0.1', 8000, {});
// Add the route
server.route({
method: 'GET',
path: '/hello',
config: {
handler: function (req) {
req.reply('hello world');
}
}
});
server.pack.require('good', {
subscribers: {
console: ['request', 'log', 'ops'],
'logs/': ['request', 'log', 'ops'],
'http://some.http.endpoint/log': ['request'],
'udp://some.syslog.server:1234': ['log']
},
leakDetection: true,
extendedRequests: true
},
function (err){
if(err){
throw err;
}
}
);
// Start the server
server.start(function(){
server.log(['info'], 'server started...');
});