Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colcode
jadx
提交
2cf6a9b6
J
jadx
项目概览
colcode
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2cf6a9b6
编写于
7月 04, 2018
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gui: fixed object reference holding by LogCollector (#302)
上级
5b712e8d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
70 addition
and
33 deletion
+70
-33
jadx-gui/src/main/java/jadx/gui/JadxGUI.java
jadx-gui/src/main/java/jadx/gui/JadxGUI.java
+1
-1
jadx-gui/src/main/java/jadx/gui/ui/LogViewer.java
jadx-gui/src/main/java/jadx/gui/ui/LogViewer.java
+4
-6
jadx-gui/src/main/java/jadx/gui/utils/logs/ILogListener.java
jadx-gui/src/main/java/jadx/gui/utils/logs/ILogListener.java
+9
-0
jadx-gui/src/main/java/jadx/gui/utils/logs/LogCollector.java
jadx-gui/src/main/java/jadx/gui/utils/logs/LogCollector.java
+30
-26
jadx-gui/src/main/java/jadx/gui/utils/logs/LogEvent.java
jadx-gui/src/main/java/jadx/gui/utils/logs/LogEvent.java
+26
-0
未找到文件。
jadx-gui/src/main/java/jadx/gui/JadxGUI.java
浏览文件 @
2cf6a9b6
...
...
@@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory;
import
jadx.gui.settings.JadxSettings
;
import
jadx.gui.settings.JadxSettingsAdapter
;
import
jadx.gui.ui.MainWindow
;
import
jadx.gui.utils.LogCollector
;
import
jadx.gui.utils.
logs.
LogCollector
;
public
class
JadxGUI
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
JadxGUI
.
class
);
...
...
jadx-gui/src/main/java/jadx/gui/ui/LogViewer.java
浏览文件 @
2cf6a9b6
...
...
@@ -7,8 +7,9 @@ import ch.qos.logback.classic.Level;
import
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
;
import
jadx.gui.settings.JadxSettings
;
import
jadx.gui.utils.LogCollector
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.logs.ILogListener
;
import
jadx.gui.utils.logs.LogCollector
;
class
LogViewer
extends
JDialog
{
private
static
final
long
serialVersionUID
=
-
2188700277429054641L
;
...
...
@@ -67,7 +68,7 @@ class LogViewer extends JDialog {
LogCollector
logCollector
=
LogCollector
.
getInstance
();
logCollector
.
resetListener
();
textPane
.
setText
(
""
);
logCollector
.
registerListener
(
new
LogCollector
.
ILogListener
()
{
logCollector
.
registerListener
(
new
ILogListener
()
{
@Override
public
Level
getFilterLevel
()
{
return
level
;
...
...
@@ -75,10 +76,7 @@ class LogViewer extends JDialog {
@Override
public
void
onAppend
(
final
String
logStr
)
{
SwingUtilities
.
invokeLater
(()
->
{
textPane
.
append
(
logStr
);
textPane
.
updateUI
();
});
SwingUtilities
.
invokeLater
(()
->
textPane
.
append
(
logStr
));
}
});
}
...
...
jadx-gui/src/main/java/jadx/gui/utils/logs/ILogListener.java
0 → 100644
浏览文件 @
2cf6a9b6
package
jadx.gui.utils.logs
;
import
ch.qos.logback.classic.Level
;
public
interface
ILogListener
{
Level
getFilterLevel
();
void
onAppend
(
String
logStr
);
}
jadx-gui/src/main/java/jadx/gui/utils/LogCollector.java
→
jadx-gui/src/main/java/jadx/gui/utils/
logs/
LogCollector.java
浏览文件 @
2cf6a9b6
package
jadx.gui.utils
;
package
jadx.gui.utils.logs
;
import
java.util.Deque
;
import
java.util.LinkedList
;
import
ch.qos.logback.classic.Level
;
import
ch.qos.logback.classic.Logger
;
import
ch.qos.logback.classic.LoggerContext
;
import
ch.qos.logback.classic.PatternLayout
;
import
ch.qos.logback.classic.spi.ILoggingEvent
;
import
ch.qos.logback.core.AppenderBase
;
import
ch.qos.logback.core.Layout
;
import
ch.qos.logback.core.read.CyclicBufferAppender
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.LoggerFactory
;
public
class
LogCollector
extends
CyclicBufferAppender
<
ILoggingEvent
>
{
p
rivate
static
LogCollector
instance
=
new
LogCollector
()
;
public
class
LogCollector
extends
AppenderBase
<
ILoggingEvent
>
{
p
ublic
static
final
int
BUFFER_SIZE
=
5000
;
private
static
final
LogCollector
INSTANCE
=
new
LogCollector
();
public
static
LogCollector
getInstance
()
{
return
instance
;
return
INSTANCE
;
}
public
static
void
register
()
{
...
...
@@ -27,18 +31,11 @@ public class LogCollector extends CyclicBufferAppender<ILoggingEvent> {
layout
.
setPattern
(
"%-5level: %msg%n"
);
layout
.
start
();
instance
.
setContext
(
loggerContext
);
instance
.
setLayout
(
layout
);
instance
.
start
();
rootLogger
.
addAppender
(
instance
);
}
public
interface
ILogListener
{
Level
getFilterLevel
();
INSTANCE
.
setContext
(
loggerContext
);
INSTANCE
.
setLayout
(
layout
);
INSTANCE
.
start
();
void
onAppend
(
String
logStr
);
rootLogger
.
addAppender
(
INSTANCE
);
}
private
Layout
<
ILoggingEvent
>
layout
;
...
...
@@ -46,20 +43,29 @@ public class LogCollector extends CyclicBufferAppender<ILoggingEvent> {
@Nullable
private
ILogListener
listener
;
private
final
Deque
<
LogEvent
>
buffer
=
new
LinkedList
<>();
public
LogCollector
()
{
setName
(
"LogCollector"
);
setMaxSize
(
5000
);
}
@Override
protected
void
append
(
ILoggingEvent
event
)
{
super
.
append
(
event
);
if
(
listener
!=
null
&&
event
.
getLevel
().
isGreaterOrEqual
(
listener
.
getFilterLevel
()))
{
synchronized
(
this
)
{
listener
.
onAppend
(
layout
.
doLayout
(
event
));
Level
level
=
event
.
getLevel
();
String
msg
=
layout
.
doLayout
(
event
);
store
(
level
,
msg
);
if
(
listener
!=
null
&&
level
.
isGreaterOrEqual
(
listener
.
getFilterLevel
()))
{
listener
.
onAppend
(
msg
);
}
}
}
private
void
store
(
Level
level
,
String
msg
)
{
buffer
.
addLast
(
new
LogEvent
(
level
,
msg
));
if
(
buffer
.
size
()
>
BUFFER_SIZE
)
{
buffer
.
pollFirst
();
}
}
public
void
setLayout
(
Layout
<
ILoggingEvent
>
layout
)
{
...
...
@@ -79,11 +85,9 @@ public class LogCollector extends CyclicBufferAppender<ILoggingEvent> {
private
String
init
(
Level
filterLevel
)
{
StringBuilder
sb
=
new
StringBuilder
();
int
length
=
getLength
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
ILoggingEvent
event
=
get
(
i
);
for
(
LogEvent
event
:
buffer
)
{
if
(
event
.
getLevel
().
isGreaterOrEqual
(
filterLevel
))
{
sb
.
append
(
layout
.
doLayout
(
event
));
sb
.
append
(
event
.
getMsg
(
));
}
}
return
sb
.
toString
();
...
...
jadx-gui/src/main/java/jadx/gui/utils/logs/LogEvent.java
0 → 100644
浏览文件 @
2cf6a9b6
package
jadx.gui.utils.logs
;
import
ch.qos.logback.classic.Level
;
final
class
LogEvent
{
private
final
Level
level
;
private
final
String
msg
;
LogEvent
(
Level
level
,
String
msg
)
{
this
.
level
=
level
;
this
.
msg
=
msg
;
}
public
Level
getLevel
()
{
return
level
;
}
public
String
getMsg
()
{
return
msg
;
}
@Override
public
String
toString
()
{
return
level
+
": "
+
msg
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录