Skip to content

Commit ee4f32b

Browse files
committed
2022.5.4-Client
1 parent 0998c38 commit ee4f32b

Some content is hidden

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

46 files changed

+131
-353
lines changed
Binary file not shown.
Binary file not shown.

.gradle/7.4/fileHashes/fileHashes.bin

4.93 KB
Binary file not shown.
0 Bytes
Binary file not shown.
1.63 KB
Binary file not shown.
Binary file not shown.
36 Bytes
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.1'
6+
version '2022.5.4'
77

88
repositories {
99
mavenCentral()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-339 Bytes
Binary file not shown.
33.2 KB
Binary file not shown.

build/reports/tests/test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ <h2>Classes</h2>
8585
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
8686
</label>
8787
</div>Generated by
88-
<a href="http://www.gradle.org">Gradle 7.4</a> at 2022年5月27日 下午12:47:24</p>
88+
<a href="http://www.gradle.org">Gradle 7.4</a> at 2022年5月27日 下午8:59:17</p>
8989
</div>
9090
</div>
9191
</body>

build/resources/test/Settings.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +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
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
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
1414
consoleInfo=true
1515
consoleDebug=true
1616
consoleError=true

build/resources/test/logs/2022-05-26 15-36-21Log.log

Lines changed: 0 additions & 18 deletions
This file was deleted.

build/resources/test/logs/2022-05-27 12-40-49Log.log

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/resources/test/logs/2022-05-27 12-45-22Log.log

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/resources/test/logs/2022-05-27 17-37-47Log.log

Lines changed: 0 additions & 15 deletions
This file was deleted.

build/resources/test/logs/2022-05-27 17-38-47Log.log

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/resources/test/logs/2022-05-27 17-39-51Log.log

Lines changed: 0 additions & 14 deletions
This file was deleted.
Binary file not shown.

build/resources/test/logs/2022-05-27 17-44-00Log.log

Lines changed: 0 additions & 14 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ void logFatal(LogEvent le, Optilog instance) {
110110
static void logCommand(String command, Optilog instance) {
111111
if (command.equals("%stop -client")) {
112112
Client.stop(instance);
113-
} else if (command.equals("%zip")) {
114-
ZipLog.zipAllLog(false, instance);
115-
} else if (command.equals("%zip -d")) {
116-
ZipLog.zipAllLog(true, instance);
113+
} else if (command.startsWith("%zip -d")) {
114+
ZipLog.zipAllLog(true, instance, command.substring(8));
115+
} else if (command.startsWith("%zip")) {
116+
ZipLog.zipAllLog(false, instance, command.substring(5));
117117
} else {
118118
try {
119119
throw new InvalidCommandException("Invalid Command '" + command + "' ", new IllegalArgumentException());
Lines changed: 22 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.optilog.log.console;
22

3-
import com.optilog.log.LogInit;
43
import com.optilog.log.Optilog;
5-
import com.optilog.util.Util;
64

75
import java.io.File;
86
import java.io.FileOutputStream;
@@ -14,172 +12,33 @@
1412
import java.util.zip.ZipOutputStream;
1513

1614
public class ZipLog {
17-
public static void zipAllLog(boolean delete, Optilog instance) {
18-
if (!instance.alreadyInit) {
19-
LogInit.initLog(instance.settingFilePath, instance);
20-
}
15+
public static void zipAllLog(boolean delete, Optilog instance, String path) {
16+
File f = new File(path + "//" + DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss(SS)").format(LocalDateTime.now()) + "LogPackage.zip");
2117
try {
22-
String s = DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss(SS)").format(LocalDateTime.now());
23-
File info = new File(instance.info.substring(0, instance.info.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
24-
File error = new File(instance.error.substring(0, instance.error.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
25-
File warn = new File(instance.warn.substring(0, instance.warn.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
26-
File debug = new File(instance.debug.substring(0, instance.debug.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
27-
File fatal = new File(instance.fatal.substring(0, instance.fatal.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
28-
try {
29-
if (!info.isFile()) {
30-
if (!info.createNewFile()) {
31-
Util.getOutput().println("Optilog Note:Failed to create zip file!");
32-
return;
33-
}
34-
}
35-
if (!error.isFile()) {
36-
if (!error.createNewFile()) {
37-
Util.getOutput().println("Optilog Note:Failed to create zip file!");
38-
return;
39-
}
40-
}
41-
if (!warn.isFile()) {
42-
if (!warn.createNewFile()) {
43-
Util.getOutput().println("Optilog Note:Failed to create zip file!");
44-
return;
45-
}
46-
}
47-
if (!debug.isFile()) {
48-
if (!debug.createNewFile()) {
49-
Util.getOutput().println("Optilog Note:Failed to create zip file!");
50-
return;
51-
}
52-
}
53-
if (!fatal.isFile()) {
54-
if (!fatal.createNewFile()) {
55-
Util.getOutput().println("Optilog Note:Failed to create zip file!");
56-
return;
57-
}
58-
}
59-
} catch (IOException e) {
60-
Util.getOutput().println("Optilog Note:Failed to create zip file!");
61-
e.printStackTrace();
62-
return;
63-
}
64-
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(info))) {
65-
File[] file = new File(instance.info.substring(0, instance.info.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
66-
if (file != null) {
67-
for (File f : file) {
68-
if (f.getName().endsWith(".log")) {
69-
output.putNextEntry(new ZipEntry(f.getName()));
70-
output.write(Files.readAllBytes(f.toPath()));
71-
output.closeEntry();
72-
if (delete) {
73-
if (!f.delete()) {
74-
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
75-
}
76-
}
77-
}
78-
}
79-
} else {
80-
instance.info("Optilog Note:No log file in info file path.");
81-
}
82-
} catch (IOException e) {
83-
instance.error("Optilog Note:Failed to pack log file.", e);
84-
}
85-
86-
if (!error.isFile()) {
87-
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(error))) {
88-
File[] file = new File(instance.error.substring(0, instance.error.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
89-
if (file != null) {
90-
for (File f : file) {
91-
if (f.getName().endsWith(".log")) {
92-
output.putNextEntry(new ZipEntry(f.getName()));
93-
output.write(Files.readAllBytes(f.toPath()));
94-
output.closeEntry();
95-
if (delete) {
96-
if (!f.delete()) {
97-
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
98-
}
99-
}
100-
}
101-
}
102-
} else {
103-
instance.info("Optilog Note:No log file in error file path.");
104-
}
105-
} catch (IOException e) {
106-
instance.error("Optilog Note:Failed to pack log file.", e);
107-
}
108-
}
109-
110-
if (!warn.isFile()) {
111-
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(warn))) {
112-
File[] file = new File(instance.warn.substring(0, instance.warn.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
113-
if (file != null) {
114-
for (File f : file) {
115-
if (f.getName().endsWith(".log")) {
116-
output.putNextEntry(new ZipEntry(f.getName()));
117-
output.write(Files.readAllBytes(f.toPath()));
118-
output.closeEntry();
119-
if (delete) {
120-
if (!f.delete()) {
121-
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
122-
}
123-
}
124-
}
125-
}
126-
} else {
127-
instance.info("Optilog Note:No log file in warn file path.");
128-
}
129-
} catch (IOException e) {
130-
instance.error("Optilog Note:Failed to pack log file.", e);
131-
}
132-
}
133-
134-
if (!debug.isFile()) {
135-
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(debug))) {
136-
File[] file = new File(instance.debug.substring(0, instance.debug.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
137-
if (file != null) {
138-
for (File f : file) {
139-
if (f.getName().endsWith(".log")) {
140-
output.putNextEntry(new ZipEntry(f.getName()));
141-
output.write(Files.readAllBytes(f.toPath()));
142-
output.closeEntry();
143-
if (delete) {
144-
if (!f.delete()) {
145-
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
146-
}
147-
}
148-
}
149-
}
150-
} else {
151-
instance.info("Optilog Note:No log file in debug file path.");
152-
}
153-
} catch (IOException e) {
154-
instance.error("Optilog Note:Failed to pack log file.", e);
155-
}
156-
}
157-
158-
if (!fatal.isFile()) {
159-
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(fatal))) {
160-
File[] file = new File(instance.fatal.substring(0, instance.fatal.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
161-
if (file != null) {
162-
for (File f : file) {
163-
if (f.getName().endsWith(".log")) {
164-
output.putNextEntry(new ZipEntry(f.getName()));
165-
output.write(Files.readAllBytes(f.toPath()));
166-
output.closeEntry();
167-
if (delete) {
168-
if (!f.delete()) {
169-
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
170-
}
171-
}
172-
}
18+
f.createNewFile();
19+
} catch (IOException e) {
20+
instance.warn("Optilog Note: Failed to create log package zip.");
21+
return;
22+
}
23+
24+
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(f))) {
25+
File[] file = new File(path).listFiles();
26+
if (file != null) {
27+
for (File fff : file) {
28+
if (fff.getName().endsWith(".log")) {
29+
output.putNextEntry(new ZipEntry(fff.getName()));
30+
output.write(Files.readAllBytes(fff.toPath()));
31+
output.closeEntry();
32+
if (delete) {
33+
fff.delete();
17334
}
174-
} else {
175-
instance.info("Optilog Note:No log file in fatal file path.");
17635
}
177-
} catch (IOException e) {
178-
instance.error("Optilog Note:Failed to pack log file.", e);
17936
}
37+
} else {
38+
instance.info("Optilog Note:No log file in fatal file path.");
18039
}
181-
} catch (StringIndexOutOfBoundsException e) {
182-
Util.getOutput().println("Please set 4 xxxxPath in setting files!");
40+
} catch (IOException e) {
41+
instance.error("Optilog Note:Failed to pack log file.", e);
18342
}
18443
}
18544
}

0 commit comments

Comments
 (0)