From c369b33b239fb3b3d365d51124bc5250d660c252 Mon Sep 17 00:00:00 2001 From: Tejas Manohar Date: Mon, 5 Oct 2015 17:51:26 -0500 Subject: [PATCH 1/2] app.silent option to turn off err logging --- lib/application.js | 2 +- test/application.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/application.js b/lib/application.js index e046726..268db39 100644 --- a/lib/application.js +++ b/lib/application.js @@ -165,7 +165,7 @@ app.onerror = function(err){ assert(err instanceof Error, 'non-error thrown: ' + err); if (404 == err.status || err.expose) return; - if ('test' == this.env) return; + if (this.silent) return; var msg = err.stack || err.toString(); console.error(); diff --git a/test/application.js b/test/application.js index acdb9e4..97a1417 100644 --- a/test/application.js +++ b/test/application.js @@ -161,8 +161,9 @@ describe('app.onerror(err)', function(){ done(); }) - it('should do nothing if env is test', function(done){ + it('should do nothing if .silent', function(done){ var app = koa(); + app.silent = true; var err = new Error(); var output = stderr.inspectSync(function() { From 6c19c41c092781d8472c1ec4c42b58f5c2d836b9 Mon Sep 17 00:00:00 2001 From: Tejas Manohar Date: Thu, 8 Oct 2015 19:02:36 -0500 Subject: [PATCH 2/2] keep test env logging for backwards-compat --- lib/application.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/application.js b/lib/application.js index 268db39..272bf9e 100644 --- a/lib/application.js +++ b/lib/application.js @@ -166,6 +166,8 @@ app.onerror = function(err){ if (404 == err.status || err.expose) return; if (this.silent) return; + // DEPRECATE env-specific logging in v2 + if ('test' == this.env) return; var msg = err.stack || err.toString(); console.error();