Skip to content

Commit 2759579

Browse files
Update v1.0.1-release
1 parent b945c89 commit 2759579

3 files changed

Lines changed: 115 additions & 15 deletions

File tree

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ dependencies {
1818
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
1919
implementation files(getToolsJar())
2020

21-
include 'org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0'
21+
include('org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0') {
22+
exclude group: 'org.apache.logging.log4j', module: 'log4j-api'
23+
}
2224
include 'org.apache.logging.log4j:log4j-api:2.0-beta9'
2325
include 'com.google.code.gson:gson:2.8.9'
2426
include 'com.formdev:flatlaf:3.7'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
org.gradle.daemon=true
22

33
project_group=com.artur114.bytecodegrab.main
4-
project_version=v1.0.0-release
4+
project_version=v1.0.1-release
55
project_archive_name=BCG
66
project_author=Artur114

src/main/java/com/artur114/bytecodegrab/agent/AgentLoggerLog4j.java

Lines changed: 111 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,162 @@
55

66
public class AgentLoggerLog4j implements IAgentLogger {
77
private final Logger logger = LogManager.getLogger("BYTECODEGARB-AGENT");
8+
private final AgentLoggerSout sout = new AgentLoggerSout();
9+
private boolean down = false;
810

911
@Override
1012
public void warn(String log) {
11-
this.logger.warn(log);
13+
if (this.down) {
14+
this.sout.warn(log);
15+
return;
16+
}
17+
try {
18+
this.logger.warn(log);
19+
} catch (Exception e) {
20+
down = true;
21+
}
1222
}
1323

1424
@Override
1525
public void info(String log) {
16-
this.logger.info(log);
26+
if (this.down) {
27+
this.sout.info(log);
28+
return;
29+
}
30+
try {
31+
this.logger.info(log);
32+
} catch (Exception e) {
33+
down = true;
34+
}
1735
}
1836

1937
@Override
2038
public void error(String log) {
21-
this.logger.error(log);
39+
if (this.down) {
40+
this.sout.error(log);
41+
return;
42+
}
43+
try {
44+
this.logger.error(log);
45+
} catch (Exception e) {
46+
down = true;
47+
}
2248
}
2349

2450
@Override
2551
public void warn(String log, Object arg) {
26-
this.logger.warn(log, arg);
52+
if (this.down) {
53+
this.sout.warn(log, arg);
54+
return;
55+
}
56+
try {
57+
this.logger.warn(log, arg);
58+
} catch (Exception e) {
59+
down = true;
60+
}
2761
}
2862

2963
@Override
3064
public void info(String log, Object arg) {
31-
this.logger.info(log, arg);
65+
if (this.down) {
66+
this.sout.info(log, arg);
67+
return;
68+
}
69+
try {
70+
this.logger.info(log, arg);
71+
} catch (Exception e) {
72+
down = true;
73+
}
3274
}
3375

3476
@Override
3577
public void error(String log, Object arg) {
36-
this.logger.error(log, arg);
78+
if (this.down) {
79+
this.sout.error(log, arg);
80+
return;
81+
}
82+
try {
83+
this.logger.error(log, arg);
84+
} catch (Exception e) {
85+
down = true;
86+
}
3787
}
3888

3989
@Override
4090
public void warn(String log, Object... args) {
41-
this.logger.warn(log, args);
91+
if (this.down) {
92+
this.sout.warn(log, args);
93+
return;
94+
}
95+
try {
96+
this.logger.warn(log, args);
97+
} catch (Exception e) {
98+
down = true;
99+
}
42100
}
43101

44102
@Override
45103
public void info(String log, Object... args) {
46-
this.logger.info(log, args);
104+
if (this.down) {
105+
this.sout.info(log, args);
106+
return;
107+
}
108+
try {
109+
this.logger.info(log, args);
110+
} catch (Exception e) {
111+
down = true;
112+
}
47113
}
48114

49115
@Override
50116
public void error(String log, Object... args) {
51-
this.logger.error(log, args);
117+
if (this.down) {
118+
this.sout.error(log, args);
119+
return;
120+
}
121+
try {
122+
this.logger.error(log, args);
123+
} catch (Exception e) {
124+
down = true;
125+
}
52126
}
53127

54128
@Override
55129
public void warn(String log, Object arg, Object arg1) {
56-
this.logger.warn(log, arg, arg1);
130+
if (this.down) {
131+
this.sout.warn(log, arg, arg1);
132+
return;
133+
}
134+
try {
135+
this.logger.warn(log, arg, arg1);
136+
} catch (Exception e) {
137+
down = true;
138+
}
57139
}
58140

59141
@Override
60142
public void info(String log, Object arg, Object arg1) {
61-
this.logger.info(log, arg, arg1);
143+
if (this.down) {
144+
this.sout.info(log, arg, arg1);
145+
return;
146+
}
147+
try {
148+
this.logger.info(log, arg, arg1);
149+
} catch (Exception e) {
150+
down = true;
151+
}
62152
}
63153

64154
@Override
65155
public void error(String log, Object arg, Object arg1) {
66-
this.logger.error(log, arg, arg1);
156+
if (this.down) {
157+
this.sout.error(log, arg, arg1);
158+
return;
159+
}
160+
try {
161+
this.logger.error(log, arg, arg1);
162+
} catch (Exception e) {
163+
down = true;
164+
}
67165
}
68-
}
166+
}

0 commit comments

Comments
 (0)