Mercurial > hg > config
annotate chrome/MozillaFileLogger.js @ 200:31249cbe4f19
Bug 629691 - pageloader.xpi does not support e10s for Tp chrome testing. r=jmaher
author | Joel Maher <jmaher@mozilla.com> |
---|---|
date | Sun, 30 Jan 2011 10:21:05 -0500 |
parents | 59d4f04497dd |
children |
rev | line source |
---|---|
198
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
1 /** |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
2 * MozillaFileLogger, a log listener that can write to a local file. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
3 */ |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
4 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
5 var ipcMode = false; // running in e10s build and need to use IPC? |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
6 try { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
7 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
8 var ipcsanity = Components.classes["@mozilla.org/preferences-service;1"] |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
9 .getService(Components.interfaces.nsIPrefBranch); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
10 ipcsanity.setIntPref("mochitest.ipcmode", 0); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
11 } catch (e) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
12 ipcMode = true; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
13 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
14 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
15 function contentDispatchEvent(type, data, sync) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
16 if (typeof(data) === "undefined") { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
17 data = {}; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
18 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
19 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
20 var element = document.createEvent("datacontainerevent"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
21 element.initEvent("contentEvent", true, false); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
22 element.setData("sync", sync); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
23 element.setData("type", type); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
24 element.setData("data", JSON.stringify(data)); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
25 document.dispatchEvent(element); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
26 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
27 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
28 function contentSyncEvent(type, data) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
29 contentDispatchEvent(type, data, 1); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
30 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
31 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
32 function contentAsyncEvent(type, data) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
33 contentDispatchEvent(type, data, 0); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
34 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
35 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
36 try { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
37 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
38 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
39 if (Cc === undefined) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
40 var Cc = Components.classes; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
41 var Ci = Components.interfaces; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
42 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
43 } catch (ex) {} //running in ipcMode-chrome |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
44 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
45 try { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
46 const FOSTREAM_CID = "@mozilla.org/network/file-output-stream;1"; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
47 const LF_CID = "@mozilla.org/file/local;1"; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
48 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
49 // File status flags. It is a bitwise OR of the following bit flags. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
50 // Only one of the first three flags below may be used. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
51 const PR_READ_ONLY = 0x01; // Open for reading only. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
52 const PR_WRITE_ONLY = 0x02; // Open for writing only. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
53 const PR_READ_WRITE = 0x04; // Open for reading and writing. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
54 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
55 // If the file does not exist, the file is created. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
56 // If the file exists, this flag has no effect. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
57 const PR_CREATE_FILE = 0x08; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
58 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
59 // The file pointer is set to the end of the file prior to each write. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
60 const PR_APPEND = 0x10; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
61 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
62 // If the file exists, its length is truncated to 0. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
63 const PR_TRUNCATE = 0x20; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
64 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
65 // If set, each write will wait for both the file data |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
66 // and file status to be physically updated. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
67 const PR_SYNC = 0x40; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
68 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
69 // If the file does not exist, the file is created. If the file already |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
70 // exists, no action and NULL is returned. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
71 const PR_EXCL = 0x80; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
72 } catch (ex) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
73 // probably not running in the test harness |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
74 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
75 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
76 /** Init the file logger with the absolute path to the file. |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
77 It will create and append if the file already exists **/ |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
78 var MozillaFileLogger = {}; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
79 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
80 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
81 MozillaFileLogger.init = function(path) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
82 if (ipcMode) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
83 contentAsyncEvent("LoggerInit", {"filename": path}); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
84 return; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
85 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
86 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
87 try { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
88 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
89 } catch (ex) {} //running in ipcMode-chrome |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
90 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
91 MozillaFileLogger._file = Cc[LF_CID].createInstance(Ci.nsILocalFile); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
92 MozillaFileLogger._file.initWithPath(path); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
93 MozillaFileLogger._foStream = Cc[FOSTREAM_CID].createInstance(Ci.nsIFileOutputStream); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
94 MozillaFileLogger._foStream.init(this._file, PR_WRITE_ONLY | PR_CREATE_FILE | PR_APPEND, |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
95 0664, 0); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
96 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
97 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
98 MozillaFileLogger.getLogCallback = function() { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
99 if (ipcMode) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
100 return function(msg) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
101 contentAsyncEvent("Logger", {"num": msg.num, "level": msg.level, "info": msg.info.join(' ')}); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
102 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
103 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
104 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
105 return function (msg) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
106 try { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
107 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
108 } catch(ex) {} //running in ipcMode-chrome |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
109 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
110 var data = msg.num + " " + msg.level + " " + msg.info.join(' ') + "\n"; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
111 if (MozillaFileLogger._foStream) |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
112 MozillaFileLogger._foStream.write(data, data.length); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
113 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
114 if (data.indexOf("SimpleTest FINISH") >= 0) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
115 MozillaFileLogger.close(); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
116 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
117 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
118 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
119 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
120 // This is only used from chrome space by the reftest harness |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
121 MozillaFileLogger.log = function(msg) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
122 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
123 if (MozillaFileLogger._foStream) |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
124 MozillaFileLogger._foStream.write(msg, msg.length); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
125 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
126 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
127 MozillaFileLogger.close = function() { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
128 if (ipcMode) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
129 contentAsyncEvent("LoggerClose"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
130 return; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
131 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
132 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
133 try { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
134 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
135 } catch(ex) {} //running in ipcMode-chrome |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
136 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
137 if(MozillaFileLogger._foStream) |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
138 MozillaFileLogger._foStream.close(); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
139 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
140 MozillaFileLogger._foStream = null; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
141 MozillaFileLogger._file = null; |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
142 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
143 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
144 if (ipcMode == false) { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
145 try { |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
146 var prefs = Components.classes['@mozilla.org/preferences-service;1'] |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
147 .getService(Components.interfaces.nsIPrefBranch2); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
148 var filename = prefs.getCharPref('talos.logfile'); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
149 MozillaFileLogger.init(filename); |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
150 } catch (ex) {} //pref does not exist, return empty string |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
151 } |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
152 |
59d4f04497dd
package into extension for profile, add direct file logging instead of stdout r=vlad
Joel Maher <jmaher@mozilla.com>
parents:
diff
changeset
|
153 |