Skip to content

Commit 7291440

Browse files
committed
2022.6.1-Client(convenient yaml setting file!(not complete))
1 parent 7a0f462 commit 7291440

File tree

12 files changed

+52
-22
lines changed

12 files changed

+52
-22
lines changed
Binary file not shown.
Binary file not shown.

.gradle/7.4/fileHashes/fileHashes.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
68 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
821 Bytes
Binary file not shown.

build/resources/test/Settings.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
info:
2+
print: true
3+
console: true
4+
server: true
5+
error:
6+
print: true
7+
console: true
8+
server: true
9+
warn:
10+
print: true
11+
console: true
12+
server: true
13+
debug:
14+
print: true
15+
console: true
16+
server: true
17+
fatal:
18+
print: true
19+
console: true
20+
server: true
21+
file:
22+
defaultConsolePath: D:\\Program\\Project\\resources\\app\\Git\\Projects\\Optilog-Client\\src\\test\\resources\\logs
23+
fileName: \%timeLog.log
24+
#Path1: ....
25+
#infoPath:%path1
26+
server:
27+
startClient: true
28+
socketNumber: 65535
29+
host: localhost
30+
packing:
31+
packingFormat: \[\%yyyy-\%MM-\%dd|\%HH:\%mm:\%ss(\%SS))\]\[\%class \%method(\%file:\%line)/\%thread ] \%level:\%msg
Binary file not shown.

src/main/java/com/optilog/setting/YamlSettings.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class YamlSettings {
1414
public static void yaml(String path, boolean isClasspath, Optilog instance) {
15-
Map<String, LinkedHashMap> map;
15+
Map<Object, LinkedHashMap> map;
1616
if (!isClasspath) {
1717
try (InputStream input = new FileInputStream(path)) {
1818
Yaml yaml = new Yaml();
@@ -31,29 +31,28 @@ public static void yaml(String path, boolean isClasspath, Optilog instance) {
3131
throw new ConfigureException("Can't find'" + path + "'.", e);
3232
}
3333
}
34-
LinkedHashMap<String, String> lInfo = map.get("info");
35-
LinkedHashMap<String, String> lError = map.get("error");
36-
LinkedHashMap<String, String> lDebug = map.get("debug");
37-
LinkedHashMap<String, String> lFatal = map.get("fatal");
38-
LinkedHashMap<String, String> lWarn = map.get("warn");
34+
LinkedHashMap<Object, Object> lInfo = map.get("info");
35+
LinkedHashMap<Object, Object> lError = map.get("error");
36+
LinkedHashMap<Object, Object> lDebug = map.get("debug");
37+
LinkedHashMap<Object, Object> lFatal = map.get("fatal");
38+
LinkedHashMap<Object, Object> lWarn = map.get("warn");
39+
instance.allSetting.printInfo = Boolean.parseBoolean(lInfo.get("print").toString());
40+
instance.allSetting.printError = Boolean.parseBoolean(lError.get("print").toString());
41+
instance.allSetting.printWarn = Boolean.parseBoolean(lWarn.get("print").toString());
42+
instance.allSetting.printDebug = Boolean.parseBoolean(lDebug.get("print").toString());
43+
instance.allSetting.printFatal = Boolean.parseBoolean(lFatal.get("print").toString());
3944

40-
instance.allSetting.printInfo = Boolean.parseBoolean(lInfo.get("print"));
41-
instance.allSetting.printError = Boolean.parseBoolean(lError.get("print"));
42-
instance.allSetting.printWarn = Boolean.parseBoolean(lWarn.get("print"));
43-
instance.allSetting.printDebug = Boolean.parseBoolean(lDebug.get("print"));
44-
instance.allSetting.printFatal = Boolean.parseBoolean(lFatal.get("print"));
45+
instance.allSetting.consoleInfo = Boolean.parseBoolean(lInfo.get("console").toString());
46+
instance.allSetting.consoleError = Boolean.parseBoolean(lError.get("console").toString());
47+
instance.allSetting.consoleDebug = Boolean.parseBoolean(lDebug.get("console").toString());
48+
instance.allSetting.consoleWarn = Boolean.parseBoolean(lWarn.get("console").toString());
49+
instance.allSetting.consoleFatal = Boolean.parseBoolean(lFatal.get("console").toString());
4550

46-
instance.allSetting.consoleInfo = Boolean.parseBoolean(lInfo.get("console"));
47-
instance.allSetting.consoleError = Boolean.parseBoolean(lError.get("console"));
48-
instance.allSetting.consoleDebug = Boolean.parseBoolean(lDebug.get("console"));
49-
instance.allSetting.consoleWarn = Boolean.parseBoolean(lWarn.get("console"));
50-
instance.allSetting.consoleFatal = Boolean.parseBoolean(lFatal.get("console"));
51-
52-
instance.allSetting.serverInfo = Boolean.parseBoolean(lInfo.get("server"));
53-
instance.allSetting.serverError = Boolean.parseBoolean(lError.get("server"));
54-
instance.allSetting.serverWarn = Boolean.parseBoolean(lWarn.get("server"));
55-
instance.allSetting.serverDebug = Boolean.parseBoolean(lDebug.get("server"));
56-
instance.allSetting.serverFatal = Boolean.parseBoolean(lFatal.get("server"));
51+
instance.allSetting.serverInfo = Boolean.parseBoolean(lInfo.get("server").toString());
52+
instance.allSetting.serverError = Boolean.parseBoolean(lError.get("server").toString());
53+
instance.allSetting.serverWarn = Boolean.parseBoolean(lWarn.get("server").toString());
54+
instance.allSetting.serverDebug = Boolean.parseBoolean(lDebug.get("server").toString());
55+
instance.allSetting.serverFatal = Boolean.parseBoolean(lFatal.get("server").toString());
5756

5857
String packing$packingFormat = (String) map.get("packing").get("packingFormat");
5958
if (packing$packingFormat != null) {

0 commit comments

Comments
 (0)