Comparing version 1.1.0 to 1.2.0
@@ -29,6 +29,8 @@ 'use strict'; | ||
let updates = []; | ||
const flush = function () { | ||
const flush = function (callback) { | ||
callback = callback || Hoek.ignore; | ||
if (!updates.length) { | ||
return; | ||
return callback(); | ||
} | ||
@@ -40,3 +42,3 @@ | ||
const payload = holder.map(JSON.stringify).join('\n'); | ||
Wreck.post(uri, { payload, headers: { 'content-type': 'application/json' }, json: true }, Hoek.ignore); // No point in loggin errors | ||
Wreck.post(uri, { payload, headers: { 'content-type': 'application/json' }, json: true }, callback); | ||
}; | ||
@@ -89,3 +91,8 @@ | ||
return next(); | ||
// Log initialization | ||
const init = internals.update('server'); | ||
init.tags = ['bananas', 'initialized']; | ||
updates.push(init); | ||
return flush(next); | ||
}; | ||
@@ -92,0 +99,0 @@ |
{ | ||
"name": "bananas", | ||
"description": "Minimal Loggly hapi plugin", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/bananas", |
@@ -37,2 +37,10 @@ 'use strict'; | ||
let updates = []; | ||
const orig = Wreck.post; | ||
Wreck.post = function (uri, options, next) { | ||
updates = updates.concat(options.payload.split('\n')); | ||
return next(); | ||
}; | ||
server.register({ register: Bananas, options: settings }, (err) => { | ||
@@ -52,9 +60,2 @@ | ||
const updates = []; | ||
const orig = Wreck.post; | ||
Wreck.post = function (uri, options, ignore) { | ||
updates.push({ uri, options }); | ||
}; | ||
server.start((err) => { | ||
@@ -68,4 +69,3 @@ | ||
const messages = updates[0].options.payload.split('\n'); | ||
expect(messages.length).to.equal(3); | ||
expect(updates.length).to.equal(4); | ||
Wreck.post = orig; | ||
@@ -78,3 +78,3 @@ | ||
}); | ||
}, 110); | ||
}, 200); | ||
}); | ||
@@ -95,2 +95,10 @@ }); | ||
let updates = []; | ||
const orig = Wreck.post; | ||
Wreck.post = function (uri, options, next) { | ||
updates = updates.concat(options.payload.split('\n')); | ||
return next(); | ||
}; | ||
server.register({ register: Bananas, options: settings }, (err) => { | ||
@@ -109,9 +117,2 @@ | ||
const updates = []; | ||
const orig = Wreck.post; | ||
Wreck.post = function (uri, options, ignore) { | ||
updates.push({ uri, options }); | ||
}; | ||
server.start((err) => { | ||
@@ -125,3 +126,3 @@ | ||
expect(updates.length).to.equal(1); | ||
expect(updates.length).to.equal(2); | ||
Wreck.post = orig; | ||
@@ -134,3 +135,3 @@ | ||
}); | ||
}, 110); | ||
}, 200); | ||
}); | ||
@@ -137,0 +138,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8531
176