Skip to content
Browse files

Now supports logging.

If a logger function is provided to the middleware factory, this will be
called every time the Chaos MonkeyWare does its mischief.
  • Loading branch information...
1 parent 42f2ca4 commit 2d18f8411bd14072b0652537f35c683fd78145eb @mikl committed Sep 6, 2012
Showing with 8 additions and 1 deletion.
  1. +4 −1 README.md
  2. +4 −0 index.js
View
5 README.md
@@ -61,7 +61,9 @@ It is used as any other Connect/Express compatible middleware.
app.use(flatiron.plugins.http);
app.http.before = [
- require('chaos-monkeyware')()
+ require('chaos-monkeyware')({
+ logger: app.log.warn
+ })
];
app.start(8080);
@@ -74,6 +76,7 @@ It is used as any other Connect/Express compatible middleware.
// If not on production, enable the Chaos Monkeyware middleware.
if (process.env.NODE_ENV !== 'production') {
apiserver.pre(require('chaos-monkeyware')({
+ logger: console.log,
probability: 0.2
}));
}
View
4 index.js
@@ -24,6 +24,10 @@ var chaos_monkeyware = module.exports = function (options) {
// that this failure was... special.
res.setHeader('ChaosMonkeyWare', mischiefName);
+ if (options.logger) {
+ options.logger('ChaosMonkeyWare mischief: ' + mischiefName);
+ }
+
return mischief[mischiefName](req, res, next);
}

0 comments on commit 2d18f84

Please sign in to comment.
Something went wrong with that request. Please try again.