diff options
Diffstat (limited to 'ext/js/yomichan.js')
-rw-r--r-- | ext/js/yomichan.js | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/ext/js/yomichan.js b/ext/js/yomichan.js index 73deeab9..107694e9 100644 --- a/ext/js/yomichan.js +++ b/ext/js/yomichan.js @@ -103,7 +103,7 @@ class Yomichan extends EventDispatcher { this.sendMessage({action: 'requestBackendReadySignal'}); await this._isBackendReadyPromise; - this.on('log', this._onForwardLog.bind(this)); + log.on('log', this._onForwardLog.bind(this)); } } @@ -156,68 +156,6 @@ class Yomichan extends EventDispatcher { }); } - logWarning(error) { - this.log(error, 'warn'); - } - - logError(error) { - this.log(error, 'error'); - } - - log(error, level, context=null) { - if (!isObject(context)) { - context = this._getLogContext(); - } - - let errorString; - try { - errorString = error.toString(); - if (/^\[object \w+\]$/.test(errorString)) { - errorString = JSON.stringify(error); - } - } catch (e) { - errorString = `${error}`; - } - - let errorStack; - try { - errorStack = (typeof error.stack === 'string' ? error.stack.trimRight() : ''); - } catch (e) { - errorStack = ''; - } - - let errorData; - try { - errorData = error.data; - } catch (e) { - // NOP - } - - if (errorStack.startsWith(errorString)) { - errorString = errorStack; - } else if (errorStack.length > 0) { - errorString += `\n${errorStack}`; - } - - let message = `${this._extensionName} has encountered a problem.`; - message += `\nOriginating URL: ${context.url}\n`; - message += errorString; - if (typeof errorData !== 'undefined') { - message += `\nData: ${JSON.stringify(errorData, null, 4)}`; - } - message += '\n\nIssues can be reported at https://github.com/FooSoft/yomichan/issues'; - - switch (level) { - case 'info': console.info(message); break; - case 'debug': console.debug(message); break; - case 'warn': console.warn(message); break; - case 'error': console.error(message); break; - default: console.log(message); break; - } - - this.trigger('log', {error, level, context}); - } - sendMessage(...args) { try { return chrome.runtime.sendMessage(...args); |