Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.debug");
14
dojo.debug = function () {
15
	if (!djConfig.isDebug) {
16
		return;
17
	}
18
	var args = arguments;
19
	if (dj_undef("println", dojo.hostenv)) {
20
		dojo.raise("dojo.debug not available (yet?)");
21
	}
22
	var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
23
	var s = [(isJUM ? "" : "DEBUG: ")];
24
	for (var i = 0; i < args.length; ++i) {
25
		if (!false && args[i] && args[i] instanceof Error) {
26
			var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) + (args[i].fileName ? ", file: " + args[i].fileName : "") + (args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]";
27
		} else {
28
			try {
29
				var msg = String(args[i]);
30
			}
31
			catch (e) {
32
				if (dojo.render.html.ie) {
33
					var msg = "[ActiveXObject]";
34
				} else {
35
					var msg = "[unknown]";
36
				}
37
			}
38
		}
39
		s.push(msg);
40
	}
41
	dojo.hostenv.println(s.join(" "));
42
};
43
dojo.debugShallow = function (obj) {
44
	if (!djConfig.isDebug) {
45
		return;
46
	}
47
	dojo.debug("------------------------------------------------------------");
48
	dojo.debug("Object: " + obj);
49
	var props = [];
50
	for (var prop in obj) {
51
		try {
52
			props.push(prop + ": " + obj[prop]);
53
		}
54
		catch (E) {
55
			props.push(prop + ": ERROR - " + E.message);
56
		}
57
	}
58
	props.sort();
59
	for (var i = 0; i < props.length; i++) {
60
		dojo.debug(props[i]);
61
	}
62
	dojo.debug("------------------------------------------------------------");
63
};
64
dojo.debugDeep = function (obj) {
65
	if (!djConfig.isDebug) {
66
		return;
67
	}
68
	if (!dojo.uri || !dojo.uri.dojoUri) {
69
		return dojo.debug("You'll need to load dojo.uri.* for deep debugging - sorry!");
70
	}
71
	if (!window.open) {
72
		return dojo.debug("Deep debugging is only supported in host environments with window.open");
73
	}
74
	var idx = dojo.debugDeep.debugVars.length;
75
	dojo.debugDeep.debugVars.push(obj);
76
	var url = (djConfig["dojoDebugDeepHtmlUrl"] || new dojo.uri.Uri(location, dojo.uri.moduleUri("dojo.debug", "deep.html")).toString()) + "?var=" + idx;
77
	var win = window.open(url, "_blank", "width=600, height=400, resizable=yes, scrollbars=yes, status=yes");
78
	try {
79
		win.debugVar = obj;
80
	}
81
	catch (e) {
82
	}
83
};
84
dojo.debugDeep.debugVars = [];
85