Skip to content
Snippets Groups Projects
Commit 1254b966 authored by Iain Bryson's avatar Iain Bryson
Browse files

Keep a list of log lines. Send javascript errors up to the server.

parent adfdce08
Branches
Tags
No related merge requests found
......@@ -10,7 +10,7 @@ var ClientDebug = {
var packet = {
level: level,
message: message
}
};
$.ajax({
method: "PUT",
......
window.ConsoleBuffer = {
current_row: 0
rows: new Array(500)
log: (message) ->
window.ConsoleBuffer.rows[window.ConsoleBuffer.current_row] = message
window.ConsoleBuffer.current_row = window.ConsoleBuffer.current_row % window.ConsoleBuffer.rows.length
nonNilRows: () ->
return window.ConsoleBuffer.rows.filter (x) ->
return x
}
window.reportABug = (ev) ->
console.log("Report a Bug")
ClientDebug.send('info', {msg: "Report a bug triggered ", location: window.location} )
ClientDebug.send('error', { type: 'user-generated', msg: "Report a bug triggered ", location: window.location.href, logs: window.ConsoleBuffer.nonNilRows() } )
window.onerror = (msg, url, lineNo, columnNo, error) ->
ClientDebug.send('error', { type: 'window.onerror', url: url, lineNo: lineNo, columnNo: columnNo, message: msg, error: error, location: document.location.href, logs: window.ConsoleBuffer.nonNilRows() } )
return false
do ->
kinds = ['log', 'warn', 'error', 'info']
for kind in kinds
oldLog = console[kind]
if typeof oldLog is 'function'
console[kind] = (message) ->
ConsoleBuffer.log({kind: kind, message: message})
oldLog.apply(console, arguments)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment