diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 41e6bfc745..26c11678c3 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -96,41 +96,7 @@ var css = csjs` } ` -var currentError - -window.addEventListener('error', function (event) { - currentError = new Error(event.message) - currentError.timeStamp = event.timeStamp - currentError.isTrusted = event.isTrusted - currentError.filename = event.filename - currentError.lineno = event.lineno - currentError.colno = event.colno - currentError.error = event.error - currentError.type = event.type -}) - -window.onerror = function (msg, url, lineno, col, error) { - if (!error) error = currentError - var val = { msg: msg, url: url, lineno: lineno, col: col, error: error } - console.error(val) -} - var KONSOLES = [] -// var KONSOLES = [{ -// error: console.error.bind(console), -// info: console.info.bind(console), -// log: console.log.bind(console) -// }] -// console.error = broadcast('error') -// console.info = broadcast('info') -// console.log = broadcast('log') -// -// function broadcast (mode) { -// return function broadcastMode () { -// var args = arguments -// KONSOLES.forEach(function (api) { api[mode].apply(api, args) }) -// } -// } function register (api) { KONSOLES.push(api) } @@ -239,8 +205,7 @@ class Terminal { delete self.scroll2bottom // @TODO: delete new message indicator } else { - // self.scroll2bottom = function () { } - // @TODO: the reattach is not working + self.scroll2bottom = function () { } // @TODO: while in stopped mode: show indicator about new lines getting logged } } @@ -338,6 +303,7 @@ class Terminal { var args = [].slice.call(arguments) var types = args.map(type) var values = javascriptserialize.apply(null, args).map(function (val, idx) { + if (typeof args[idx] === 'string') val = args[idx] if (types[idx] === 'element') val = jsbeautify.html(val) var pattern = '.{1,' + self.data.lineLength + '}' var lines = val.match(new RegExp(pattern, 'g')) @@ -374,6 +340,16 @@ class Terminal { }) }) } + info () { + var self = this + var args = [...arguments].map(x => ({ type: 'info', value: x })) + self.log.apply(self, args) + } + error () { + var self = this + var args = [...arguments].map(x => ({ type: 'error', value: x })) + self.log.apply(self, args) + } scroll2bottom () { var self = this setTimeout(function () {