From 2cab200e4190da9ccdb873760dafcc14373fa5c5 Mon Sep 17 00:00:00 2001 From: coding Date: Tue, 24 Oct 2017 10:41:57 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DJava=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=89=93=E5=8D=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/core/console.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/resources/core/console.js b/src/main/resources/core/console.js index d41fb21..398c62c 100644 --- a/src/main/resources/core/console.js +++ b/src/main/resources/core/console.js @@ -4,6 +4,7 @@ /*global base*/ var log = base.getLog().static; (function(global){ + var Arrays = Java.type('java.util.Arrays'); var Level = Java.type('java.util.logging.Level'); var Console = function (name) { Object.defineProperty(this, 'name', { @@ -27,11 +28,23 @@ var log = base.getLog().static; this.debug = function () { log.d(this.name + Array.prototype.join.call(arguments, ' ')); } + this.sender = function () { + var args = Array.prototype.slice.call(arguments, 1); + log.sender(); + } this.ex = function (ex) { log.console('§4' + ex); - ex.getStackTrace().forEach(function (stack) { - log.console(' §e位于 §c%s §4行%s', stack.fileName, stack.lineNumber); - }); + var track = ex.getStackTrace(); + if (track.class) { track = Arrays.asList(track) } + if (track.forEach) { + track.forEach(function (stack) { + if (stack.className.startsWith('<')) { + log.console(' §e位于 §c%s => §c%s §4行%s', stack.fileName, stack.methodName, stack.lineNumber); + } else { + log.console(' §e位于 §c%s.%s(§4%s:%s§c)', stack.className, stack.methodName, stack.fileName, stack.lineNumber); + } + }); + } } } global.Console = Console;