Skip to content

Commit ff4a89a

Browse files
committed
2022.5.3.1-Client
1 parent b635023 commit ff4a89a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+303
-205
lines changed
Binary file not shown.
Binary file not shown.

.gradle/7.4/fileHashes/fileHashes.bin

750 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
782 Bytes
Binary file not shown.
Binary file not shown.

.gradle/file-system.probe

0 Bytes
Binary file not shown.

.gradle/workspace-id.txt.lock

0 Bytes
Binary file not shown.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group 'com.optilog'
6-
version '2022.5.3'
6+
version '2022.5.3.1'
77

88
repositories {
99
mavenCentral()
-174 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
54 Bytes
Binary file not shown.
33.7 KB
Binary file not shown.

build/resources/test/Settings.properties

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ printError=true
33
printWarn=true
44
printDebug=true
55
printFatal=true
6-
defaultConsolePath=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources\\logs
6+
#defaultConsolePath=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources\\logs
7+
Path1=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources\\logs
8+
Path2=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources
9+
infoPath=%path1
10+
errorPath=%path2
11+
warnPath=%path1
12+
debugPath=%path1
13+
fatalPath=%path2
714
consoleInfo=true
815
consoleDebug=true
916
consoleError=true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[2022-05-27|17:37:47(29))][com.optilog.OptilogTest main(OptilogTest.java:8)/main] info:---常规输出测试---
2+
[2022-05-27|17:37:47(32))][com.optilog.OptilogTest main(OptilogTest.java:9)/main] info:infojava.lang.Object@65e2dbf3
3+
[2022-05-27|17:37:47(33))][com.optilog.OptilogTest main(OptilogTest.java:10)/main] Error:error
4+
[2022-05-27|17:37:47(33))][com.optilog.OptilogTest main(OptilogTest.java:11)/main] debug:debug32.0
5+
[2022-05-27|17:37:47(34))][com.optilog.OptilogTest main(OptilogTest.java:14)/main] Warning:warnnull
6+
[2022-05-27|17:37:47(34))][com.optilog.OptilogTest main(OptilogTest.java:15)/main] info:---占位符---
7+
[2022-05-27|17:37:47(35))][com.optilog.OptilogTest main(OptilogTest.java:16)/main] info:1 2
8+
[2022-05-27|17:37:47(35))][com.optilog.OptilogTest main(OptilogTest.java:17)/main] Error:1 1
9+
[2022-05-27|17:37:47(35))][com.optilog.OptilogTest main(OptilogTest.java:18)/main] Warning:null
10+
[2022-05-27|17:37:47(36))][com.optilog.OptilogTest main(OptilogTest.java:19)/main] debug:1 2 #3
11+
[2022-05-27|17:37:47(36))][com.optilog.OptilogTest main(OptilogTest.java:21)/main] debug:de
12+
[2022-05-27|17:37:47(36))][com.optilog.OptilogTest test(OptilogTest.java:26)/main] Warning:---变化栈测试---
13+
[2022-05-27|17:37:47(37))][com.optilog.OptilogTest test(OptilogTest.java:27)/main] info:info(test)
14+
[2022-05-27|17:37:47(37))][com.optilog.OptilogTest test(OptilogTest.java:29)/main] info:$
15+
[2022-05-27|17:37:47(37))][com.optilog.OptilogTest lambda$test$1(OptilogTest.java:28)/Thread-0] info:hello
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[2022-05-27|17:38:47(65))][com.optilog.OptilogTest main(OptilogTest.java:8)/main] info:---常规输出测试---
2+
[2022-05-27|17:38:47(68))][com.optilog.OptilogTest main(OptilogTest.java:9)/main] info:infojava.lang.Object@2b9627bc
3+
[2022-05-27|17:38:47(69))][com.optilog.OptilogTest main(OptilogTest.java:15)/main] info:---占位符---
4+
[2022-05-27|17:38:47(70))][com.optilog.OptilogTest main(OptilogTest.java:16)/main] info:1 2
5+
[2022-05-27|17:38:47(71))][com.optilog.OptilogTest test(OptilogTest.java:27)/main] info:info(test)
6+
[2022-05-27|17:38:47(71))][com.optilog.OptilogTest test(OptilogTest.java:29)/main] info:$
7+
[2022-05-27|17:38:47(71))][com.optilog.OptilogTest lambda$test$1(OptilogTest.java:28)/Thread-0] info:hello
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[2022-05-27|17:39:51(05))][com.optilog.Test main(Test.java:8)/main] info:
2+
[2022-05-27|17:39:51(08))][com.optilog.log.Optilog getAllField(Optilog.java:826)/main] info:
3+
class com.optilog.log.Optilog -> com.optilog.log.Optilog@369f73a2:
4+
socket(class java.net.DatagramSocket) = java.net.DatagramSocket@67b92f0a
5+
consoleFileMasterCaution(boolean) = true
6+
alreadyInit(boolean) = true
7+
allSetting(class com.optilog.setting.SettingFiles) = com.optilog.setting.SettingFiles@65e2dbf3
8+
settingFilePath(class java.lang.String) = %prop -cp /Settings.properties
9+
info(class java.lang.String) = D:\Program\Feishu\app\assets\object\apps\Intellij-IDEA\Project\Optilog-Client\src\test\resources\logs\2022-05-27 17-39-51Log.log
10+
error(class java.lang.String) =
11+
warn(class java.lang.String) =
12+
debug(class java.lang.String) =
13+
fatal(class java.lang.String) =
14+
end
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[2022-05-27|17:44:00(96))][com.optilog.Test main(Test.java:8)/main] info:
2+
[2022-05-27|17:44:00(98))][com.optilog.log.Optilog getAllField(Optilog.java:826)/main] info:
3+
class com.optilog.log.Optilog -> com.optilog.log.Optilog@369f73a2:
4+
socket(class java.net.DatagramSocket) = java.net.DatagramSocket@67b92f0a
5+
consoleFileMasterCaution(boolean) = true
6+
alreadyInit(boolean) = true
7+
allSetting(class com.optilog.setting.SettingFiles) = com.optilog.setting.SettingFiles@65e2dbf3
8+
settingFilePath(class java.lang.String) = %prop -cp /Settings.properties
9+
info(class java.lang.String) = D:\Program\Feishu\app\assets\object\apps\Intellij-IDEA\Project\Optilog-Client\src\test\resources\logs\2022-05-27 17-44-00Log.log
10+
error(class java.lang.String) = D:\Program\Feishu\app\assets\object\apps\Intellij-IDEA\Project\Optilog-Client\src\test\resources\2022-05-27 17-44-00Log.log
11+
warn(class java.lang.String) = D:\Program\Feishu\app\assets\object\apps\Intellij-IDEA\Project\Optilog-Client\src\test\resources\logs\2022-05-27 17-44-00Log.log
12+
debug(class java.lang.String) = D:\Program\Feishu\app\assets\object\apps\Intellij-IDEA\Project\Optilog-Client\src\test\resources\logs\2022-05-27 17-44-00Log.log
13+
fatal(class java.lang.String) = D:\Program\Feishu\app\assets\object\apps\Intellij-IDEA\Project\Optilog-Client\src\test\resources\2022-05-27 17-44-00Log.log
14+
end
Binary file not shown.
Binary file not shown.

src/main/java/com/optilog/log/Log.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44

55
public interface Log {
66
static Optilog initLog(String pathOfSettingFile) {
7-
Optilog optilog = new Optilog();
8-
optilog.settingFilePath = pathOfSettingFile;
9-
optilog.alreadyInit = false;
10-
return optilog;
7+
return new Optilog(pathOfSettingFile, false);
118
}
129

1310
static Optilog reInitLog(String pathOfSettingFile) {
14-
Optilog optilog = new Optilog();
15-
optilog.settingFilePath = pathOfSettingFile;
16-
optilog.alreadyInit = false;
17-
return optilog;
11+
return new Optilog(pathOfSettingFile, false);
1812
}
1913

2014
void info();
@@ -170,8 +164,4 @@ static Optilog reInitLog(String pathOfSettingFile) {
170164
void setServerFatal(boolean serverFatal);
171165

172166
void getAllField(Object instance);
173-
174-
void shutdown();
175-
176-
void shutdownNow();
177167
}

src/main/java/com/optilog/log/LogEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.optilog.log;
22

33
public class LogEvent {
4-
public String message;
4+
public volatile String message;
55

6-
public Level level;
6+
public volatile Level level;
77

88
@Deprecated
99
public String getMessage() {

src/main/java/com/optilog/log/LogInit.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
import com.optilog.util.exception.OptilogException;
1010

1111
import java.io.IOException;
12-
import java.util.concurrent.Executors;
1312

1413
public class LogInit {
1514
@OnlyInInit
1615
public static void initLog(String settingFilePath, Optilog instance) {
17-
instance.logThread = Executors.newCachedThreadPool();
1816
if (settingFilePath.isBlank()) {
1917
instance.consoleFileMasterCaution = false;
2018
instance.allSetting = new SettingFiles();

src/main/java/com/optilog/log/Optilog.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55

66
import java.lang.reflect.Field;
77
import java.net.DatagramSocket;
8-
import java.util.concurrent.ExecutorService;
98
import java.util.regex.Matcher;
109
import java.util.regex.Pattern;
1110

1211
public class Optilog implements Log {
13-
public volatile ExecutorService logThread;
14-
1512
public volatile DatagramSocket socket;
1613
public volatile boolean consoleFileMasterCaution = true;
1714
public volatile boolean alreadyInit;
@@ -26,14 +23,9 @@ public class Optilog implements Log {
2623
public volatile String debug = "";
2724
public volatile String fatal = "";
2825

29-
@Override
30-
public void shutdown() {
31-
this.logThread.shutdown();
32-
}
33-
34-
@Override
35-
public void shutdownNow() {
36-
this.logThread.shutdownNow();
26+
Optilog(String var1, boolean alreadyInit) {
27+
this.settingFilePath = var1;
28+
this.alreadyInit = alreadyInit;
3729
}
3830

3931
@Override

src/main/java/com/optilog/log/Send.java

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,68 +24,58 @@ void loggerConsole(String level, String message, Optilog instance) {
2424
try {
2525
if (instance.consoleFileMasterCaution && Level.INFO.getName().equals(level) && !instance.info.isBlank()) {
2626
String s = Packing.packMessage(message, level, instance);
27-
instance.logThread.submit(() -> {
28-
try {
29-
synchronized (Send.INSTANCE) {
30-
Files.writeString(Path.of(instance.info), Files.readString(Path.of(instance.info), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
31-
}
32-
} catch (IOException e) {
33-
instance.consoleFileMasterCaution = false;
34-
instance.error("Optilog Note:Java throws Exception when log is output", e);
27+
try {
28+
synchronized (Send.INSTANCE) {
29+
Files.writeString(Path.of(instance.info), Files.readString(Path.of(instance.info), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
3530
}
36-
});
31+
} catch (IOException e) {
32+
instance.consoleFileMasterCaution = false;
33+
instance.error("Optilog Note:Java throws Exception when log is output", e);
34+
}
3735
}
3836
if (instance.consoleFileMasterCaution && Level.ERROR.getName().equals(level) && !instance.error.isBlank()) {
3937
String s = Packing.packMessage(message, level, instance);
40-
instance.logThread.submit(() -> {
41-
try {
42-
synchronized (Send.INSTANCE) {
43-
Files.writeString(Path.of(instance.error), Files.readString(Path.of(instance.error), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
44-
}
45-
} catch (IOException e) {
46-
instance.consoleFileMasterCaution = false;
47-
instance.error("Optilog Note:Java throws Exception when log is output", e);
38+
try {
39+
synchronized (Send.INSTANCE) {
40+
Files.writeString(Path.of(instance.error), Files.readString(Path.of(instance.error), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
4841
}
49-
});
42+
} catch (IOException e) {
43+
instance.consoleFileMasterCaution = false;
44+
instance.error("Optilog Note:Java throws Exception when log is output", e);
45+
}
5046
}
5147
if (instance.consoleFileMasterCaution && Level.DEBUG.getName().equals(level) && !instance.debug.isBlank()) {
5248
String s = Packing.packMessage(message, level, instance);
53-
instance.logThread.submit(() -> {
54-
try {
55-
synchronized (Send.INSTANCE) {
56-
Files.writeString(Path.of(instance.debug), Files.readString(Path.of(instance.debug), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
57-
}
58-
} catch (IOException e) {
59-
instance.consoleFileMasterCaution = false;
60-
instance.error("Optilog Note:Java throws Exception when log is output", e);
49+
try {
50+
synchronized (Send.INSTANCE) {
51+
Files.writeString(Path.of(instance.debug), Files.readString(Path.of(instance.debug), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
6152
}
62-
});
53+
} catch (IOException e) {
54+
instance.consoleFileMasterCaution = false;
55+
instance.error("Optilog Note:Java throws Exception when log is output", e);
56+
}
6357
}
6458
if (instance.consoleFileMasterCaution && Level.WARN.getName().equals(level) && !instance.warn.isBlank()) {
6559
String s = Packing.packMessage(message, level, instance);
66-
instance.logThread.submit(() -> {
67-
try {
68-
synchronized (Send.INSTANCE) {
69-
Files.writeString(Path.of(instance.warn), Files.readString(Path.of(instance.warn), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
70-
}
71-
} catch (IOException e) {
72-
instance.consoleFileMasterCaution = false;
73-
instance.error("Optilog Note:Java throws Exception when log is output", e);
60+
try {
61+
synchronized (Send.INSTANCE) {
62+
Files.writeString(Path.of(instance.warn), Files.readString(Path.of(instance.warn), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
7463
}
75-
});
64+
} catch (IOException e) {
65+
instance.consoleFileMasterCaution = false;
66+
instance.error("Optilog Note:Java throws Exception when log is output", e);
67+
}
7668
}
7769
if (instance.consoleFileMasterCaution && Level.FATAL.getName().equals(level) && !instance.fatal.isBlank()) {
7870
String s = Packing.packMessage(message, level, instance);
79-
instance.logThread.submit(() -> {
80-
try {
81-
synchronized (Send.INSTANCE) {
82-
Files.writeString(Path.of(instance.fatal), Files.readString(Path.of(instance.fatal), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
83-
}
84-
} catch (IOException e) {
85-
instance.consoleFileMasterCaution = false;
86-
instance.error("Optilog Note:Java throws Exception when log is output", e);
71+
try {
72+
synchronized (Send.INSTANCE) {
73+
Files.writeString(Path.of(instance.fatal), Files.readString(Path.of(instance.fatal), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
8774
}
88-
});
75+
} catch (IOException e) {
76+
instance.consoleFileMasterCaution = false;
77+
instance.error("Optilog Note:Java throws Exception when log is output", e);
78+
}
8979
}
9080
} catch (RuntimeException e) {
9181
instance.consoleFileMasterCaution = false;
@@ -98,7 +88,7 @@ void loggerToServer(final String level, String message, final Optilog instance)
9888
synchronized (Send.INSTANCE) {
9989
message = Packing.packMessage(message, level, instance);
10090
String finalMessage = message;
101-
instance.logThread.submit(() -> Client.send(finalMessage + level, instance));
91+
Client.send(finalMessage + level, instance);
10292
}
10393
}
10494
}

src/main/java/com/optilog/log/console/Console.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public class Console {
1313
@OnlyInInit
1414
public static void file(Optilog instance) {
1515
if (instance.consoleFileMasterCaution) {
16-
1716
if (instance.allSetting != null) {
1817
instance.allSetting.fileName = instance.allSetting.fileName.replace("%time", DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss").format(LocalDateTime.now()));
1918
} else {
@@ -55,7 +54,6 @@ public static void file(Optilog instance) {
5554
if (!file.createNewFile()) {
5655
throw new IOException("Create new file failed!");
5756
}
58-
5957
}
6058
instance.allSetting.Path1 = file.getAbsolutePath();
6159
} catch (IOException e) {
@@ -133,8 +131,7 @@ public static void file(Optilog instance) {
133131
instance.info = instance.allSetting.Path5;
134132
}
135133
if (instance.info.equals("")) {
136-
instance.consoleFileMasterCaution = false;
137-
Util.getOutput().println("Optilog Note:Init console failed.");
134+
instance.allSetting.consoleInfo = false;
138135
}
139136
} catch (NullPointerException e) {
140137
instance.consoleFileMasterCaution = false;
@@ -159,8 +156,7 @@ public static void file(Optilog instance) {
159156
instance.error = instance.allSetting.Path5;
160157
}
161158
if (instance.error.equals("")) {
162-
instance.consoleFileMasterCaution = false;
163-
Util.getOutput().println("Optilog Note:Init console failed.");
159+
instance.allSetting.consoleError = false;
164160
}
165161
} catch (NullPointerException e) {
166162
instance.consoleFileMasterCaution = false;
@@ -185,8 +181,7 @@ public static void file(Optilog instance) {
185181
instance.warn = instance.allSetting.Path5;
186182
}
187183
if (instance.warn.equals("")) {
188-
instance.consoleFileMasterCaution = false;
189-
Util.getOutput().println("Optilog Note:Init console failed.");
184+
instance.allSetting.consoleWarn = false;
190185
}
191186
} catch (NullPointerException e) {
192187
instance.consoleFileMasterCaution = false;
@@ -211,8 +206,7 @@ public static void file(Optilog instance) {
211206
instance.debug = instance.allSetting.Path5;
212207
}
213208
if (instance.debug.equals("")) {
214-
instance.consoleFileMasterCaution = false;
215-
Util.getOutput().println("Optilog Note:Init console failed.");
209+
instance.allSetting.consoleDebug = false;
216210
}
217211
} catch (NullPointerException e) {
218212
instance.consoleFileMasterCaution = false;
@@ -237,8 +231,7 @@ public static void file(Optilog instance) {
237231
instance.fatal = instance.allSetting.Path5;
238232
}
239233
if (instance.fatal.equals("")) {
240-
instance.consoleFileMasterCaution = false;
241-
Util.getOutput().println("Optilog Note:Init console failed.");
234+
instance.allSetting.consoleFatal = false;
242235
}
243236
} catch (NullPointerException e) {
244237
instance.consoleFileMasterCaution = false;

0 commit comments

Comments
 (0)