OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.Object} | 7 * @extends {WebInspector.Object} |
8 */ | 8 */ |
9 WebInspector.Console = function() | 9 WebInspector.Console = function() |
10 { | 10 { |
(...skipping 25 matching lines...) Expand all Loading... |
36 * @param {boolean} show | 36 * @param {boolean} show |
37 */ | 37 */ |
38 WebInspector.Console.Message = function(text, level, timestamp, show) | 38 WebInspector.Console.Message = function(text, level, timestamp, show) |
39 { | 39 { |
40 this.text = text; | 40 this.text = text; |
41 this.level = level; | 41 this.level = level; |
42 this.timestamp = (typeof timestamp === "number") ? timestamp : Date.now(); | 42 this.timestamp = (typeof timestamp === "number") ? timestamp : Date.now(); |
43 this.show = show; | 43 this.show = show; |
44 } | 44 } |
45 | 45 |
| 46 /** |
| 47 * @interface |
| 48 */ |
| 49 WebInspector.Console.UIDelegate = function() |
| 50 { |
| 51 } |
| 52 |
| 53 WebInspector.Console.UIDelegate.prototype = { |
| 54 showConsole: function() { } |
| 55 } |
| 56 |
46 WebInspector.Console.prototype = { | 57 WebInspector.Console.prototype = { |
47 /** | 58 /** |
| 59 * @param {!WebInspector.Console.UIDelegate} uiDelegate |
| 60 */ |
| 61 setUIDelegate: function(uiDelegate) |
| 62 { |
| 63 this._uiDelegate = uiDelegate; |
| 64 }, |
| 65 |
| 66 /** |
48 * @param {string} text | 67 * @param {string} text |
49 * @param {!WebInspector.Console.MessageLevel} level | 68 * @param {!WebInspector.Console.MessageLevel} level |
50 * @param {boolean=} show | 69 * @param {boolean=} show |
51 */ | 70 */ |
52 addMessage: function(text, level, show) | 71 addMessage: function(text, level, show) |
53 { | 72 { |
54 var message = new WebInspector.Console.Message(text, level || WebInspect
or.Console.MessageLevel.Log, Date.now(), show || false); | 73 var message = new WebInspector.Console.Message(text, level || WebInspect
or.Console.MessageLevel.Log, Date.now(), show || false); |
55 this._messages.push(message); | 74 this._messages.push(message); |
56 this.dispatchEventToListeners(WebInspector.Console.Events.MessageAdded,
message); | 75 this.dispatchEventToListeners(WebInspector.Console.Events.MessageAdded,
message); |
57 }, | 76 }, |
58 | 77 |
59 /** | 78 /** |
60 * @param {string} text | 79 * @param {string} text |
61 * @param {boolean=} show | |
62 */ | 80 */ |
63 addErrorMessage: function(text, show) | 81 log: function(text) |
64 { | 82 { |
65 this.addMessage(text, WebInspector.Console.MessageLevel.Error, show); | 83 this.addMessage(text, WebInspector.Console.MessageLevel.Log); |
66 }, | 84 }, |
67 | 85 |
68 /** | 86 /** |
| 87 * @param {string} text |
| 88 */ |
| 89 warn: function(text) |
| 90 { |
| 91 this.addMessage(text, WebInspector.Console.MessageLevel.Warning); |
| 92 }, |
| 93 |
| 94 /** |
| 95 * @param {string} text |
| 96 */ |
| 97 error: function(text) |
| 98 { |
| 99 this.addMessage(text, WebInspector.Console.MessageLevel.Error, true); |
| 100 }, |
| 101 |
| 102 /** |
69 * @return {!Array.<!WebInspector.Console.Message>} | 103 * @return {!Array.<!WebInspector.Console.Message>} |
70 */ | 104 */ |
71 messages: function() | 105 messages: function() |
72 { | 106 { |
73 return this._messages; | 107 return this._messages; |
74 }, | 108 }, |
75 | 109 |
| 110 show: function() |
| 111 { |
| 112 if (this._uiDelegate) |
| 113 this._uiDelegate.showConsole(); |
| 114 }, |
| 115 |
76 __proto__: WebInspector.Object.prototype | 116 __proto__: WebInspector.Object.prototype |
77 } | 117 } |
78 | 118 |
79 WebInspector.console = new WebInspector.Console(); | 119 WebInspector.console = new WebInspector.Console(); |
OLD | NEW |