|
16 | 16 | log_level: 1, |
17 | 17 | native_error:false, |
18 | 18 | use_console:false, |
| 19 | + hijack_console:true, |
19 | 20 | query_var: 'msg', |
20 | 21 | client_info: { |
21 | 22 | location:false, |
|
106 | 107 | * The function that will send error logs to the server. Also logs to the console using console.error() (if available and requested by the user) |
107 | 108 | * @param what What you want to be logged (String, or JSON object) |
108 | 109 | */ |
109 | | - var original_error = console.error; |
110 | | - console.error = function(what) { |
| 110 | + $.error = function(what) { |
111 | 111 | if (defaults.log_level >= 1) { |
112 | 112 | _send(defaults.error_url, what); |
113 | 113 | } |
114 | 114 |
|
115 | | - if ( original_error.apply ) { |
| 115 | + if (defaults.hijack_console && original_error.apply) { |
116 | 116 | original_error.apply(this, arguments); |
117 | 117 | } |
118 | 118 | }; |
119 | 119 |
|
| 120 | + if (defaults.hijack_console) { |
| 121 | + var original_error = console.error; |
| 122 | + console.error = $.error; |
| 123 | + } |
| 124 | + |
120 | 125 | /** |
121 | 126 | * The function that will send info logs to the server. Also logs to the console using console.info() (if available and requested by the user) |
122 | 127 | * @param what What you want to be logged (String, or JSON object) |
123 | 128 | */ |
124 | | - var original_info = console.info; |
125 | | - console.info = function(what) { |
| 129 | + $.info = function(what) { |
126 | 130 | if (defaults.log_level >= 3) { |
127 | 131 | _send(defaults.info_url, what); |
128 | 132 | } |
129 | 133 |
|
130 | | - if ( origin_info.apply ) { |
| 134 | + if (defaults.hijack_console && origin_info.apply) { |
131 | 135 | original_info.apply(this, arguments); |
132 | 136 | } |
133 | 137 | }; |
134 | 138 |
|
| 139 | + if (defaults.hijack_console) { |
| 140 | + var original_info = console.info; |
| 141 | + console.info = $.info; |
| 142 | + } |
| 143 | + |
135 | 144 | /** |
136 | 145 | * The function that will send standard logs to the server. Also logs to the console using console.log() (if available and requested by the user) |
137 | 146 | * @param what What you want to be logged (String, or JSON object) |
138 | 147 | */ |
139 | | - var original_log = console.log; |
140 | | - console.log = function(what) { |
| 148 | + $.log = function(what) { |
141 | 149 | if (defaults.log_level >= 2) { |
142 | 150 | _send(defaults.log_url, what); |
143 | 151 | } |
144 | 152 |
|
145 | | - if ( original_log.apply ) { |
| 153 | + if (defaults.hijack_console && original_log.apply) { |
146 | 154 | original_log.apply(this, arguments); |
147 | 155 | } |
148 | 156 | }; |
149 | 157 |
|
| 158 | + if (defaults.hijack_console) { |
| 159 | + var original_log = console.log; |
| 160 | + console.log = $.log; |
| 161 | + } |
| 162 | + |
150 | 163 | // Log errors whenever there's a generic js error on the page. |
151 | 164 | window.onerror = function(message, file, line) { |
152 | 165 | if (defaults.native_error) { |
|
0 commit comments