Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
2cf6a9b6
Commit
2cf6a9b6
authored
Jul 03, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gui: fixed object reference holding by LogCollector (#302)
parent
5b712e8d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
33 deletions
+70
-33
JadxGUI.java
jadx-gui/src/main/java/jadx/gui/JadxGUI.java
+1
-1
LogViewer.java
jadx-gui/src/main/java/jadx/gui/ui/LogViewer.java
+4
-6
ILogListener.java
jadx-gui/src/main/java/jadx/gui/utils/logs/ILogListener.java
+9
-0
LogCollector.java
jadx-gui/src/main/java/jadx/gui/utils/logs/LogCollector.java
+30
-26
LogEvent.java
jadx-gui/src/main/java/jadx/gui/utils/logs/LogEvent.java
+26
-0
No files found.
jadx-gui/src/main/java/jadx/gui/JadxGUI.java
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment