Skip to content

Commit

Permalink
2022.5.3.1-Client
Browse files Browse the repository at this point in the history
  • Loading branch information
OptiJava committed May 27, 2022
1 parent b635023 commit ff4a89a
Show file tree
Hide file tree
Showing 45 changed files with 303 additions and 205 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/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'
version '2022.5.3.1'

repositories {
mavenCentral()
Expand Down
Binary file modified build/classes/java/main/com/optilog/log/Log.class
Binary file not shown.
Binary file modified build/classes/java/main/com/optilog/log/LogEvent.class
Binary file not shown.
Binary file modified build/classes/java/main/com/optilog/log/LogInit.class
Binary file not shown.
Binary file modified build/classes/java/main/com/optilog/log/Optilog.class
Binary file not shown.
Binary file modified build/classes/java/main/com/optilog/log/Send.class
Binary file not shown.
Binary file modified build/classes/java/main/com/optilog/log/console/Console.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/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.3.1.jar
Binary file not shown.
9 changes: 8 additions & 1 deletion build/resources/test/Settings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +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
#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
15 changes: 15 additions & 0 deletions build/resources/test/logs/2022-05-27 17-37-47Log.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[2022-05-27|17:37:47(29))][com.optilog.OptilogTest main(OptilogTest.java:8)/main] info:---常规输出测试---
[2022-05-27|17:37:47(32))][com.optilog.OptilogTest main(OptilogTest.java:9)/main] info:infojava.lang.Object@65e2dbf3
[2022-05-27|17:37:47(33))][com.optilog.OptilogTest main(OptilogTest.java:10)/main] Error:error
[2022-05-27|17:37:47(33))][com.optilog.OptilogTest main(OptilogTest.java:11)/main] debug:debug32.0
[2022-05-27|17:37:47(34))][com.optilog.OptilogTest main(OptilogTest.java:14)/main] Warning:warnnull
[2022-05-27|17:37:47(34))][com.optilog.OptilogTest main(OptilogTest.java:15)/main] info:---占位符---
[2022-05-27|17:37:47(35))][com.optilog.OptilogTest main(OptilogTest.java:16)/main] info:1 2
[2022-05-27|17:37:47(35))][com.optilog.OptilogTest main(OptilogTest.java:17)/main] Error:1 1
[2022-05-27|17:37:47(35))][com.optilog.OptilogTest main(OptilogTest.java:18)/main] Warning:null
[2022-05-27|17:37:47(36))][com.optilog.OptilogTest main(OptilogTest.java:19)/main] debug:1 2 #3
[2022-05-27|17:37:47(36))][com.optilog.OptilogTest main(OptilogTest.java:21)/main] debug:de
[2022-05-27|17:37:47(36))][com.optilog.OptilogTest test(OptilogTest.java:26)/main] Warning:---变化栈测试---
[2022-05-27|17:37:47(37))][com.optilog.OptilogTest test(OptilogTest.java:27)/main] info:info(test)
[2022-05-27|17:37:47(37))][com.optilog.OptilogTest test(OptilogTest.java:29)/main] info:$
[2022-05-27|17:37:47(37))][com.optilog.OptilogTest lambda$test$1(OptilogTest.java:28)/Thread-0] info:hello
7 changes: 7 additions & 0 deletions build/resources/test/logs/2022-05-27 17-38-47Log.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[2022-05-27|17:38:47(65))][com.optilog.OptilogTest main(OptilogTest.java:8)/main] info:---常规输出测试---
[2022-05-27|17:38:47(68))][com.optilog.OptilogTest main(OptilogTest.java:9)/main] info:infojava.lang.Object@2b9627bc
[2022-05-27|17:38:47(69))][com.optilog.OptilogTest main(OptilogTest.java:15)/main] info:---占位符---
[2022-05-27|17:38:47(70))][com.optilog.OptilogTest main(OptilogTest.java:16)/main] info:1 2
[2022-05-27|17:38:47(71))][com.optilog.OptilogTest test(OptilogTest.java:27)/main] info:info(test)
[2022-05-27|17:38:47(71))][com.optilog.OptilogTest test(OptilogTest.java:29)/main] info:$
[2022-05-27|17:38:47(71))][com.optilog.OptilogTest lambda$test$1(OptilogTest.java:28)/Thread-0] info:hello
14 changes: 14 additions & 0 deletions build/resources/test/logs/2022-05-27 17-39-51Log.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[2022-05-27|17:39:51(05))][com.optilog.Test main(Test.java:8)/main] info:
[2022-05-27|17:39:51(08))][com.optilog.log.Optilog getAllField(Optilog.java:826)/main] info:
class com.optilog.log.Optilog -> com.optilog.log.Optilog@369f73a2:
socket(class java.net.DatagramSocket) = java.net.DatagramSocket@67b92f0a
consoleFileMasterCaution(boolean) = true
alreadyInit(boolean) = true
allSetting(class com.optilog.setting.SettingFiles) = com.optilog.setting.SettingFiles@65e2dbf3
settingFilePath(class java.lang.String) = %prop -cp /Settings.properties
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
error(class java.lang.String) =
warn(class java.lang.String) =
debug(class java.lang.String) =
fatal(class java.lang.String) =
end
Binary file not shown.
14 changes: 14 additions & 0 deletions build/resources/test/logs/2022-05-27 17-44-00Log.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[2022-05-27|17:44:00(96))][com.optilog.Test main(Test.java:8)/main] info:
[2022-05-27|17:44:00(98))][com.optilog.log.Optilog getAllField(Optilog.java:826)/main] info:
class com.optilog.log.Optilog -> com.optilog.log.Optilog@369f73a2:
socket(class java.net.DatagramSocket) = java.net.DatagramSocket@67b92f0a
consoleFileMasterCaution(boolean) = true
alreadyInit(boolean) = true
allSetting(class com.optilog.setting.SettingFiles) = com.optilog.setting.SettingFiles@65e2dbf3
settingFilePath(class java.lang.String) = %prop -cp /Settings.properties
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
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
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
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
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
end
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.
14 changes: 2 additions & 12 deletions src/main/java/com/optilog/log/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@

public interface Log {
static Optilog initLog(String pathOfSettingFile) {
Optilog optilog = new Optilog();
optilog.settingFilePath = pathOfSettingFile;
optilog.alreadyInit = false;
return optilog;
return new Optilog(pathOfSettingFile, false);
}

static Optilog reInitLog(String pathOfSettingFile) {
Optilog optilog = new Optilog();
optilog.settingFilePath = pathOfSettingFile;
optilog.alreadyInit = false;
return optilog;
return new Optilog(pathOfSettingFile, false);
}

void info();
Expand Down Expand Up @@ -170,8 +164,4 @@ static Optilog reInitLog(String pathOfSettingFile) {
void setServerFatal(boolean serverFatal);

void getAllField(Object instance);

void shutdown();

void shutdownNow();
}
4 changes: 2 additions & 2 deletions src/main/java/com/optilog/log/LogEvent.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.optilog.log;

public class LogEvent {
public String message;
public volatile String message;

public Level level;
public volatile Level level;

@Deprecated
public String getMessage() {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/optilog/log/LogInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import com.optilog.util.exception.OptilogException;

import java.io.IOException;
import java.util.concurrent.Executors;

public class LogInit {
@OnlyInInit
public static void initLog(String settingFilePath, Optilog instance) {
instance.logThread = Executors.newCachedThreadPool();
if (settingFilePath.isBlank()) {
instance.consoleFileMasterCaution = false;
instance.allSetting = new SettingFiles();
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/com/optilog/log/Optilog.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@

import java.lang.reflect.Field;
import java.net.DatagramSocket;
import java.util.concurrent.ExecutorService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Optilog implements Log {
public volatile ExecutorService logThread;

public volatile DatagramSocket socket;
public volatile boolean consoleFileMasterCaution = true;
public volatile boolean alreadyInit;
Expand All @@ -26,14 +23,9 @@ public class Optilog implements Log {
public volatile String debug = "";
public volatile String fatal = "";

@Override
public void shutdown() {
this.logThread.shutdown();
}

@Override
public void shutdownNow() {
this.logThread.shutdownNow();
Optilog(String var1, boolean alreadyInit) {
this.settingFilePath = var1;
this.alreadyInit = alreadyInit;
}

@Override
Expand Down
82 changes: 36 additions & 46 deletions src/main/java/com/optilog/log/Send.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,68 +24,58 @@ void loggerConsole(String level, String message, Optilog instance) {
try {
if (instance.consoleFileMasterCaution && Level.INFO.getName().equals(level) && !instance.info.isBlank()) {
String s = Packing.packMessage(message, level, instance);
instance.logThread.submit(() -> {
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.info), Files.readString(Path.of(instance.info), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.info), Files.readString(Path.of(instance.info), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
});
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
}
}
if (instance.consoleFileMasterCaution && Level.ERROR.getName().equals(level) && !instance.error.isBlank()) {
String s = Packing.packMessage(message, level, instance);
instance.logThread.submit(() -> {
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.error), Files.readString(Path.of(instance.error), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.error), Files.readString(Path.of(instance.error), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
});
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
}
}
if (instance.consoleFileMasterCaution && Level.DEBUG.getName().equals(level) && !instance.debug.isBlank()) {
String s = Packing.packMessage(message, level, instance);
instance.logThread.submit(() -> {
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.debug), Files.readString(Path.of(instance.debug), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.debug), Files.readString(Path.of(instance.debug), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
});
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
}
}
if (instance.consoleFileMasterCaution && Level.WARN.getName().equals(level) && !instance.warn.isBlank()) {
String s = Packing.packMessage(message, level, instance);
instance.logThread.submit(() -> {
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.warn), Files.readString(Path.of(instance.warn), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.warn), Files.readString(Path.of(instance.warn), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
});
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
}
}
if (instance.consoleFileMasterCaution && Level.FATAL.getName().equals(level) && !instance.fatal.isBlank()) {
String s = Packing.packMessage(message, level, instance);
instance.logThread.submit(() -> {
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.fatal), Files.readString(Path.of(instance.fatal), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
try {
synchronized (Send.INSTANCE) {
Files.writeString(Path.of(instance.fatal), Files.readString(Path.of(instance.fatal), StandardCharsets.UTF_8) + s, StandardCharsets.UTF_8);
}
});
} catch (IOException e) {
instance.consoleFileMasterCaution = false;
instance.error("Optilog Note:Java throws Exception when log is output", e);
}
}
} catch (RuntimeException e) {
instance.consoleFileMasterCaution = false;
Expand All @@ -98,7 +88,7 @@ void loggerToServer(final String level, String message, final Optilog instance)
synchronized (Send.INSTANCE) {
message = Packing.packMessage(message, level, instance);
String finalMessage = message;
instance.logThread.submit(() -> Client.send(finalMessage + level, instance));
Client.send(finalMessage + level, instance);
}
}
}
17 changes: 5 additions & 12 deletions src/main/java/com/optilog/log/console/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class Console {
@OnlyInInit
public static void file(Optilog instance) {
if (instance.consoleFileMasterCaution) {

if (instance.allSetting != null) {
instance.allSetting.fileName = instance.allSetting.fileName.replace("%time", DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss").format(LocalDateTime.now()));
} else {
Expand Down Expand Up @@ -55,7 +54,6 @@ public static void file(Optilog instance) {
if (!file.createNewFile()) {
throw new IOException("Create new file failed!");
}

}
instance.allSetting.Path1 = file.getAbsolutePath();
} catch (IOException e) {
Expand Down Expand Up @@ -133,8 +131,7 @@ public static void file(Optilog instance) {
instance.info = instance.allSetting.Path5;
}
if (instance.info.equals("")) {
instance.consoleFileMasterCaution = false;
Util.getOutput().println("Optilog Note:Init console failed.");
instance.allSetting.consoleInfo = false;
}
} catch (NullPointerException e) {
instance.consoleFileMasterCaution = false;
Expand All @@ -159,8 +156,7 @@ public static void file(Optilog instance) {
instance.error = instance.allSetting.Path5;
}
if (instance.error.equals("")) {
instance.consoleFileMasterCaution = false;
Util.getOutput().println("Optilog Note:Init console failed.");
instance.allSetting.consoleError = false;
}
} catch (NullPointerException e) {
instance.consoleFileMasterCaution = false;
Expand All @@ -185,8 +181,7 @@ public static void file(Optilog instance) {
instance.warn = instance.allSetting.Path5;
}
if (instance.warn.equals("")) {
instance.consoleFileMasterCaution = false;
Util.getOutput().println("Optilog Note:Init console failed.");
instance.allSetting.consoleWarn = false;
}
} catch (NullPointerException e) {
instance.consoleFileMasterCaution = false;
Expand All @@ -211,8 +206,7 @@ public static void file(Optilog instance) {
instance.debug = instance.allSetting.Path5;
}
if (instance.debug.equals("")) {
instance.consoleFileMasterCaution = false;
Util.getOutput().println("Optilog Note:Init console failed.");
instance.allSetting.consoleDebug = false;
}
} catch (NullPointerException e) {
instance.consoleFileMasterCaution = false;
Expand All @@ -237,8 +231,7 @@ public static void file(Optilog instance) {
instance.fatal = instance.allSetting.Path5;
}
if (instance.fatal.equals("")) {
instance.consoleFileMasterCaution = false;
Util.getOutput().println("Optilog Note:Init console failed.");
instance.allSetting.consoleFatal = false;
}
} catch (NullPointerException e) {
instance.consoleFileMasterCaution = false;
Expand Down
Loading

0 comments on commit ff4a89a

Please sign in to comment.