How to send the log console of the browser developer?

I have a web app in JS, with all due personal belongings: AppCache, WebSQL and all that. Not the most difficult, the lines that way for a couple of thousand.

The user complains that something is not working. The reasons for this can meet anywhere in the code and this place will either throw an exception or issue an error to the console.

How to make log console last X minutes will be sent to the developers when the user clicks on a special button?
Or even better: send just the fact that the developers specify in advance as potentially problematic place uncaught errors and so on?

Interested in only mobile Safari and mobile Chrome, other browsers are not needed.
July 9th 19 at 13:35
3 answers
July 9th 19 at 13:37
Don't know how to send the log by pressing the button, and if the error is critical, then it is likely that the js on the page is not working and no button is pressed will not be processed. I perehvatyvat and logarou on the backend all the bugs of the frontend. Before all scripts to connect on the page is and it

window.onerror = function(err, url, line, col, msg) {
 var data = {
 'Error': err,
 'URL': url,
 'Line': line,
 'Column': null,
 'Message': null,
 'Browser': null,
 'OS': null,
 'Device': null

 // HTML5 only
 data['Column'] = !col ? ": col;
 data['Message'] = !msg ? ": msg;

 try {
 var ua = detect.parse(navigator.userAgent); 
 data['Browser'] = ! ? ":;
 data['OS'] = ! ? ":;
 data['Device'] = ! ? ":;
 catch(e) {}

 console.groupCollapsed('Error:' + data['Error']);
 console.log('URL:' + data['URL']);
 console.log('Line:' + data['Line']);
 console.log('Column:' + data['Column']);
 console.log('Message:' + data['Message']);

 try {
 $.post('/frontend/error/', data);
 catch(e) {}

 return true; //suppressErrorAlert

and on the server to configure the handler, preserving the resulting error in the file.
This solves another problem, but thanks anyway. - twila.Kozey commented on July 9th 19 at 13:40
July 9th 19 at 13:39
Either I do not understand humor, or for mobile browsers, this method is not suitable. - twila.Kozey commented on July 9th 19 at 13:42
July 9th 19 at 13:41
In your case you can only override the console object and in addition to the console output to record strings in an array, and when you click the array to send to the server.

Find more questions by tags JavaScriptBrowsersWeb Development