Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.debug");
12
dojo.debug = function () {
13
	if (!djConfig.isDebug) {
14
		return;
15
	}
16
	var args = arguments;
17
	if (dj_undef("println", dojo.hostenv)) {
18
		dojo.raise("dojo.debug not available (yet?)");
19
	}
20
	var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
21
	var s = [(isJUM ? "" : "DEBUG: ")];
22
	for (var i = 0; i < args.length; ++i) {
23
		if (!false && args[i] && args[i] instanceof Error) {
24
			var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) + (args[i].fileName ? ", file: " + args[i].fileName : "") + (args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]";
25
		} else {
26
			try {
27
				var msg = String(args[i]);
28
			}
29
			catch (e) {
30
				if (dojo.render.html.ie) {
31
					var msg = "[ActiveXObject]";
32
				} else {
33
					var msg = "[unknown]";
34
				}
35
			}
36
		}
37
		s.push(msg);
38
	}
39
	dojo.hostenv.println(s.join(" "));
40
};
41
dojo.debugShallow = function (obj) {
42
	if (!djConfig.isDebug) {
43
		return;
44
	}
45
	dojo.debug("------------------------------------------------------------");
46
	dojo.debug("Object: " + obj);
47
	var props = [];
48
	for (var prop in obj) {
49
		try {
50
			props.push(prop + ": " + obj[prop]);
51
		}
52
		catch (E) {
53
			props.push(prop + ": ERROR - " + E.message);
54
		}
55
	}
56
	props.sort();
57
	for (var i = 0; i < props.length; i++) {
58
		dojo.debug(props[i]);
59
	}
60
	dojo.debug("------------------------------------------------------------");
61
};
62
dojo.debugDeep = function (obj) {
63
	if (!djConfig.isDebug) {
64
		return;
65
	}
66
	if (!dojo.uri || !dojo.uri.dojoUri) {
67
		return dojo.debug("You'll need to load dojo.uri.* for deep debugging - sorry!");
68
	}
69
	if (!window.open) {
70
		return dojo.debug("Deep debugging is only supported in host environments with window.open");
71
	}
72
	var idx = dojo.debugDeep.debugVars.length;
73
	dojo.debugDeep.debugVars.push(obj);
74
	var url = (djConfig["dojoDebugDeepHtmlUrl"] || new dojo.uri.Uri(location, dojo.uri.moduleUri("dojo.debug", "deep.html")).toString()) + "?var=" + idx;
75
	var win = window.open(url, "_blank", "width=600, height=400, resizable=yes, scrollbars=yes, status=yes");
76
	try {
77
		win.debugVar = obj;
78
	}
79
	catch (e) {
80
	}
81
};
82
dojo.debugDeep.debugVars = [];
83