Skip to content

Commit

Permalink
2022.5.4-Client
Browse files Browse the repository at this point in the history
  • Loading branch information
OptiJava committed May 27, 2022
1 parent 0998c38 commit ee4f32b
Show file tree
Hide file tree
Showing 46 changed files with 131 additions and 353 deletions.
Binary file modified .gradle/7.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
Binary file modified .gradle/workspace-id.txt.lock
Binary file not shown.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'com.optilog'
version '2022.5.3.1'
version '2022.5.4'

repositories {
mavenCentral()
Expand Down
Binary file modified build/classes/java/main/com/optilog/log/Logger.class
Binary file not shown.
Binary file modified build/classes/java/main/com/optilog/log/console/ZipLog.class
Binary file not shown.
Binary file modified build/classes/java/main/com/optilog/setting/SettingFiles.class
Binary file not shown.
Binary file modified build/classes/java/test/com/optilog/OptilogTest.class
Binary file not shown.
Binary file modified build/classes/java/test/com/optilog/PerformanceTester.class
Binary file not shown.
Binary file modified build/classes/java/test/com/optilog/Test.class
Binary file not shown.
Binary file added build/libs/Optilog-Client-2022.5.4.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion build/reports/tests/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h2>Classes</h2>
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label>
</div>Generated by
<a href="http://www.gradle.org">Gradle 7.4</a> at 2022年5月27日 下午12:47:24</p>
<a href="http://www.gradle.org">Gradle 7.4</a> at 2022年5月27日 下午8:59:17</p>
</div>
</div>
</body>
Expand Down
16 changes: 8 additions & 8 deletions build/resources/test/Settings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ printError=true
printWarn=true
printDebug=true
printFatal=true
#defaultConsolePath=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources\\logs
Path1=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources\\logs
Path2=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources
infoPath=%path1
errorPath=%path2
warnPath=%path1
debugPath=%path1
fatalPath=%path2
defaultConsolePath=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources\\logs
#Path1=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources\\logs
#Path2=D:\\Program\\Feishu\\app\\assets\\object\\apps\\Intellij-IDEA\\Project\\Optilog-Client\\src\\test\\resources
#infoPath=%path1
#errorPath=%path2
#warnPath=%path1
#debugPath=%path1
#fatalPath=%path2
consoleInfo=true
consoleDebug=true
consoleError=true
Expand Down
18 changes: 0 additions & 18 deletions build/resources/test/logs/2022-05-26 15-36-21Log.log

This file was deleted.

1 change: 0 additions & 1 deletion build/resources/test/logs/2022-05-27 12-40-49Log.log

This file was deleted.

1 change: 0 additions & 1 deletion build/resources/test/logs/2022-05-27 12-45-22Log.log

This file was deleted.

15 changes: 0 additions & 15 deletions build/resources/test/logs/2022-05-27 17-37-47Log.log

This file was deleted.

7 changes: 0 additions & 7 deletions build/resources/test/logs/2022-05-27 17-38-47Log.log

This file was deleted.

14 changes: 0 additions & 14 deletions build/resources/test/logs/2022-05-27 17-39-51Log.log

This file was deleted.

Binary file not shown.
14 changes: 0 additions & 14 deletions build/resources/test/logs/2022-05-27 17-44-00Log.log

This file was deleted.

Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
Binary file modified build/tmp/compileTestJava/previous-compilation-data.bin
Binary file not shown.
8 changes: 4 additions & 4 deletions src/main/java/com/optilog/log/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ void logFatal(LogEvent le, Optilog instance) {
static void logCommand(String command, Optilog instance) {
if (command.equals("%stop -client")) {
Client.stop(instance);
} else if (command.equals("%zip")) {
ZipLog.zipAllLog(false, instance);
} else if (command.equals("%zip -d")) {
ZipLog.zipAllLog(true, instance);
} else if (command.startsWith("%zip -d")) {
ZipLog.zipAllLog(true, instance, command.substring(8));
} else if (command.startsWith("%zip")) {
ZipLog.zipAllLog(false, instance, command.substring(5));
} else {
try {
throw new InvalidCommandException("Invalid Command '" + command + "' ", new IllegalArgumentException());
Expand Down
185 changes: 22 additions & 163 deletions src/main/java/com/optilog/log/console/ZipLog.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.optilog.log.console;

import com.optilog.log.LogInit;
import com.optilog.log.Optilog;
import com.optilog.util.Util;

import java.io.File;
import java.io.FileOutputStream;
Expand All @@ -14,172 +12,33 @@
import java.util.zip.ZipOutputStream;

public class ZipLog {
public static void zipAllLog(boolean delete, Optilog instance) {
if (!instance.alreadyInit) {
LogInit.initLog(instance.settingFilePath, instance);
}
public static void zipAllLog(boolean delete, Optilog instance, String path) {
File f = new File(path + "//" + DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss(SS)").format(LocalDateTime.now()) + "LogPackage.zip");
try {
String s = DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss(SS)").format(LocalDateTime.now());
File info = new File(instance.info.substring(0, instance.info.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
File error = new File(instance.error.substring(0, instance.error.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
File warn = new File(instance.warn.substring(0, instance.warn.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
File debug = new File(instance.debug.substring(0, instance.debug.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
File fatal = new File(instance.fatal.substring(0, instance.fatal.length() - (instance.allSetting.fileName.length() + 1)) + "//" + s + "LogPackage.zip");
try {
if (!info.isFile()) {
if (!info.createNewFile()) {
Util.getOutput().println("Optilog Note:Failed to create zip file!");
return;
}
}
if (!error.isFile()) {
if (!error.createNewFile()) {
Util.getOutput().println("Optilog Note:Failed to create zip file!");
return;
}
}
if (!warn.isFile()) {
if (!warn.createNewFile()) {
Util.getOutput().println("Optilog Note:Failed to create zip file!");
return;
}
}
if (!debug.isFile()) {
if (!debug.createNewFile()) {
Util.getOutput().println("Optilog Note:Failed to create zip file!");
return;
}
}
if (!fatal.isFile()) {
if (!fatal.createNewFile()) {
Util.getOutput().println("Optilog Note:Failed to create zip file!");
return;
}
}
} catch (IOException e) {
Util.getOutput().println("Optilog Note:Failed to create zip file!");
e.printStackTrace();
return;
}
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(info))) {
File[] file = new File(instance.info.substring(0, instance.info.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
if (file != null) {
for (File f : file) {
if (f.getName().endsWith(".log")) {
output.putNextEntry(new ZipEntry(f.getName()));
output.write(Files.readAllBytes(f.toPath()));
output.closeEntry();
if (delete) {
if (!f.delete()) {
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
}
}
}
}
} else {
instance.info("Optilog Note:No log file in info file path.");
}
} catch (IOException e) {
instance.error("Optilog Note:Failed to pack log file.", e);
}

if (!error.isFile()) {
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(error))) {
File[] file = new File(instance.error.substring(0, instance.error.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
if (file != null) {
for (File f : file) {
if (f.getName().endsWith(".log")) {
output.putNextEntry(new ZipEntry(f.getName()));
output.write(Files.readAllBytes(f.toPath()));
output.closeEntry();
if (delete) {
if (!f.delete()) {
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
}
}
}
}
} else {
instance.info("Optilog Note:No log file in error file path.");
}
} catch (IOException e) {
instance.error("Optilog Note:Failed to pack log file.", e);
}
}

if (!warn.isFile()) {
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(warn))) {
File[] file = new File(instance.warn.substring(0, instance.warn.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
if (file != null) {
for (File f : file) {
if (f.getName().endsWith(".log")) {
output.putNextEntry(new ZipEntry(f.getName()));
output.write(Files.readAllBytes(f.toPath()));
output.closeEntry();
if (delete) {
if (!f.delete()) {
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
}
}
}
}
} else {
instance.info("Optilog Note:No log file in warn file path.");
}
} catch (IOException e) {
instance.error("Optilog Note:Failed to pack log file.", e);
}
}

if (!debug.isFile()) {
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(debug))) {
File[] file = new File(instance.debug.substring(0, instance.debug.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
if (file != null) {
for (File f : file) {
if (f.getName().endsWith(".log")) {
output.putNextEntry(new ZipEntry(f.getName()));
output.write(Files.readAllBytes(f.toPath()));
output.closeEntry();
if (delete) {
if (!f.delete()) {
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
}
}
}
}
} else {
instance.info("Optilog Note:No log file in debug file path.");
}
} catch (IOException e) {
instance.error("Optilog Note:Failed to pack log file.", e);
}
}

if (!fatal.isFile()) {
try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(fatal))) {
File[] file = new File(instance.fatal.substring(0, instance.fatal.length() - (instance.allSetting.fileName.length() + 1))).listFiles();
if (file != null) {
for (File f : file) {
if (f.getName().endsWith(".log")) {
output.putNextEntry(new ZipEntry(f.getName()));
output.write(Files.readAllBytes(f.toPath()));
output.closeEntry();
if (delete) {
if (!f.delete()) {
instance.warn("Optilog Note:Delete #1 failed!", f.getName());
}
}
}
f.createNewFile();
} catch (IOException e) {
instance.warn("Optilog Note: Failed to create log package zip.");
return;
}

try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(f))) {
File[] file = new File(path).listFiles();
if (file != null) {
for (File fff : file) {
if (fff.getName().endsWith(".log")) {
output.putNextEntry(new ZipEntry(fff.getName()));
output.write(Files.readAllBytes(fff.toPath()));
output.closeEntry();
if (delete) {
fff.delete();
}
} else {
instance.info("Optilog Note:No log file in fatal file path.");
}
} catch (IOException e) {
instance.error("Optilog Note:Failed to pack log file.", e);
}
} else {
instance.info("Optilog Note:No log file in fatal file path.");
}
} catch (StringIndexOutOfBoundsException e) {
Util.getOutput().println("Please set 4 xxxxPath in setting files!");
} catch (IOException e) {
instance.error("Optilog Note:Failed to pack log file.", e);
}
}
}
Loading

0 comments on commit ee4f32b

Please sign in to comment.