From 0fd167a41d1c6aeec24994d2fcf4eaf3c8b87ea7 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Sun, 18 Aug 2013 23:11:32 -0700 Subject: [PATCH] Use DEBUG or NODE_DEBUG env to override the debug flag --- lib/datasource.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/datasource.js b/lib/datasource.js index 3a58e935..1049ec51 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -176,7 +176,14 @@ DataSource.prototype.setup = function(name, settings) { // just save everything we get this.name = name; - this.settings = settings; + this.settings = settings || {}; + + // Check the debug env settings + var debugEnv = process.env.DEBUG || process.env.NODE_DEBUG || ''; + var debugModules = debugEnv.split(/[\s,]+/); + if(debugModules.indexOf('loopback') !== -1) { + this.settings.debug = true; + } // Disconnected by default this.connected = false;