DebugUtils.jsm
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
30 EXPORTED_SYMBOLS = ["DebugUtils"];
31 
32 const Cc = Components.classes;
33 const Ci = Components.interfaces;
34 const Cr = Components.results
35 
36 var DebugUtils = {
40  get logModules() {
41  let environment = Cc["@mozilla.org/process/environment;1"]
42  .createInstance(Ci.nsIEnvironment);
43  let result = environment.get("NSPR_LOG_MODULES");
44 
45  // Memoize the result
46  this.__defineGetter__("logModules", function() result);
47  return this.logModules;
48  },
49 
61  generateLogFunction: function DebugUtils_generateLogFunction(module, level) {
62  let doLog = false;
63  let minLevel = 3;
64  if (arguments.length > 1) {
65  minLevel = parseInt(arguments[1]);
66  }
67  for each (let entry in this.logModules.split(/,/)) {
68  if (/(.*):(\d+)$/.test(entry) &&
69  (RegExp.$1 == module || RegExp.$1 == "all") &&
70  parseInt(RegExp.$2) >= minLevel) {
71  doLog = true;
72  }
73  }
74 
75  if (doLog) {
76  return function LOG(msg) {
77  dump(module + ": " + msg + "\n");
78  };
79  }
80  else {
81  return function LOG(msg) {};
82  }
83  }
84 };
classDescription entry
Definition: FeedWriter.js:1427
#define LOG(args)
EXPORTED_SYMBOLS
Definition: DebugUtils.jsm:30
const Ci
Definition: DebugUtils.jsm:33
const Cr
Definition: DebugUtils.jsm:34
function d(s)
const module
Definition: httpd.js:4659
return!aWindow arguments!aWindow arguments[0]
function msg
__defineGetter__("Application", function(){delete this.Application;return this.Application=Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication);})
const Cc
Definition: DebugUtils.jsm:32