util: always display a warning for module in debug mode
authorMaciej Małecki <maciej.malecki@notimplemented.org>
Mon, 16 Jan 2012 12:54:35 +0000 (13:54 +0100)
committerFedor Indutny <fedor.indutny@gmail.com>
Mon, 16 Jan 2012 13:19:56 +0000 (19:19 +0600)
lib/util.js

index 8cc4739..834dc67 100644 (file)
@@ -522,15 +522,16 @@ exports.inherits = function(ctor, superCtor) {
 var deprecationWarnings;
 
 exports._deprecationWarning = function(moduleId, message) {
-  if (!deprecationWarnings)
-    deprecationWarnings = {};
-  else if (message in deprecationWarnings)
-    return;
-
-  deprecationWarnings[message] = true;
-
-  if ((new RegExp('\\b' + moduleId + '\\b')).test(process.env.NODE_DEBUG))
+  if ((new RegExp('\\b' + moduleId + '\\b')).test(process.env.NODE_DEBUG)) {
     console.trace(message);
-  else
+  } else {
+    if (!deprecationWarnings) {
+      deprecationWarnings = {};
+    } else if (message in deprecationWarnings) {
+      return;
+    }
     console.error(message);
+
+    deprecationWarnings[message] = true;
+  }
 };