Skip to content

Commit fa34d2e

Browse files
committed
2022.6.4-Snapshot-Client(add json support(not complete),edit README)
1 parent f1326d6 commit fa34d2e

File tree

4 files changed

+217
-36
lines changed

4 files changed

+217
-36
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5+
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
6+
<title>Test results - OptilogTest</title>
7+
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
8+
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
9+
<script src="../js/report.js" type="text/javascript"></script>
10+
</head>
11+
<body>
12+
<div id="content">
13+
<h1>OptilogTest</h1>
14+
<div class="breadcrumbs">
15+
<a href="../index.html">all</a> &gt;
16+
<a href="../packages/com.optilog.html">com.optilog</a> &gt; OptilogTest</div>
17+
<div id="summary">
18+
<table>
19+
<tr>
20+
<td>
21+
<div class="summaryGroup">
22+
<table>
23+
<tr>
24+
<td>
25+
<div class="infoBox" id="tests">
26+
<div class="counter">1</div>
27+
<p>tests</p>
28+
</div>
29+
</td>
30+
<td>
31+
<div class="infoBox" id="failures">
32+
<div class="counter">0</div>
33+
<p>failures</p>
34+
</div>
35+
</td>
36+
<td>
37+
<div class="infoBox" id="ignored">
38+
<div class="counter">0</div>
39+
<p>ignored</p>
40+
</div>
41+
</td>
42+
<td>
43+
<div class="infoBox" id="duration">
44+
<div class="counter">0.420s</div>
45+
<p>duration</p>
46+
</div>
47+
</td>
48+
</tr>
49+
</table>
50+
</div>
51+
</td>
52+
<td>
53+
<div class="infoBox success" id="successRate">
54+
<div class="percent">100%</div>
55+
<p>successful</p>
56+
</div>
57+
</td>
58+
</tr>
59+
</table>
60+
</div>
61+
<div id="tabs">
62+
<ul class="tabLinks">
63+
<li>
64+
<a href="#tab0">Tests</a>
65+
</li>
66+
<li>
67+
<a href="#tab1">Standard output</a>
68+
</li>
69+
<li>
70+
<a href="#tab2">Standard error</a>
71+
</li>
72+
</ul>
73+
<div id="tab0" class="tab">
74+
<h2>Tests</h2>
75+
<table>
76+
<thead>
77+
<tr>
78+
<th>Test</th>
79+
<th>Duration</th>
80+
<th>Result</th>
81+
</tr>
82+
</thead>
83+
<tr>
84+
<td class="success">test()</td>
85+
<td class="success">0.420s</td>
86+
<td class="success">passed</td>
87+
</tr>
88+
</table>
89+
</div>
90+
<div id="tab1" class="tab">
91+
<h2>Standard output</h2>
92+
<span class="code">
93+
<pre>[2022-06-14|19:26:01(78))][com.optilog.OptilogTest test(OptilogTest.java:12)/Test worker] info:---常规输出测试---
94+
[2022-06-14|19:26:01(79))][com.optilog.OptilogTest test(OptilogTest.java:13)/Test worker] info:infojava.lang.Object@549621f3
95+
[2022-06-14|19:26:01(80))][com.optilog.OptilogTest test(OptilogTest.java:14)/Test worker] Error:error
96+
[2022-06-14|19:26:01(80))][com.optilog.OptilogTest test(OptilogTest.java:15)/Test worker] debug:debug32.0
97+
[2022-06-14|19:26:01(80))][com.optilog.OptilogTest test(OptilogTest.java:16)/Test worker] FATAL:null
98+
[2022-06-14|19:26:01(81))][com.optilog.OptilogTest test(OptilogTest.java:17)/Test worker] FATAL:null
99+
[2022-06-14|19:26:01(81))][com.optilog.OptilogTest test(OptilogTest.java:18)/Test worker] Warning:warnnull
100+
[2022-06-14|19:26:01(82))][com.optilog.OptilogTest test(OptilogTest.java:19)/Test worker] info:---占位符---
101+
[2022-06-14|19:26:01(83))][com.optilog.OptilogTest test(OptilogTest.java:20)/Test worker] info:1 2
102+
[2022-06-14|19:26:01(83))][com.optilog.OptilogTest test(OptilogTest.java:21)/Test worker] Error:1 1
103+
[2022-06-14|19:26:01(84))][com.optilog.OptilogTest test(OptilogTest.java:22)/Test worker] Warning:null
104+
[2022-06-14|19:26:01(84))][com.optilog.OptilogTest test(OptilogTest.java:23)/Test worker] debug:1 2 #3
105+
[2022-06-14|19:26:01(85))][com.optilog.OptilogTest test(OptilogTest.java:24)/Test worker] FATAL:1 #2
106+
[2022-06-14|19:26:01(85))][com.optilog.OptilogTest test(OptilogTest.java:25)/Test worker] debug:de
107+
[2022-06-14|19:26:01(85))][com.optilog.OptilogTest test(OptilogTest.java:26)/Test worker] test:t!e!s!t!
108+
[2022-06-14|19:26:01(86))][com.optilog.OptilogTest test(OptilogTest.java:33)/Test worker] Warning:---变化栈测试---
109+
[2022-06-14|19:26:01(86))][com.optilog.OptilogTest test(OptilogTest.java:34)/Test worker] info:info(test)
110+
[2022-06-14|19:26:01(87))][com.optilog.OptilogTest test(OptilogTest.java:36)/Test worker] info:$
111+
[2022-06-14|19:26:01(87))][com.optilog.OptilogTest lambda$test$1(OptilogTest.java:35)/Thread-3] info:hello
112+
19
113+
[2022-06-14|19:26:01(88)][com.optilog.OptilogTest test(OptilogTest.java:41)/Test worker] info:log2
114+
</pre>
115+
</span>
116+
</div>
117+
<div id="tab2" class="tab">
118+
<h2>Standard error</h2>
119+
<span class="code">
120+
<pre>[2022-06-14|19:26:01(79))][com.optilog.OptilogTest test(OptilogTest.java:14)/Test worker] Error:error
121+
[2022-06-14|19:26:01(80))][com.optilog.OptilogTest test(OptilogTest.java:16)/Test worker] FATAL:null
122+
[2022-06-14|19:26:01(80))][com.optilog.OptilogTest test(OptilogTest.java:17)/Test worker] FATAL:null
123+
[2022-06-14|19:26:01(83))][com.optilog.OptilogTest test(OptilogTest.java:21)/Test worker] Error:1 1
124+
[2022-06-14|19:26:01(84))][com.optilog.OptilogTest test(OptilogTest.java:24)/Test worker] FATAL:1 #2
125+
</pre>
126+
</span>
127+
</div>
128+
</div>
129+
<div id="footer">
130+
<p>
131+
<div>
132+
<label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines
133+
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
134+
</label>
135+
</div>Generated by
136+
<a href="http://www.gradle.org">Gradle 7.4</a> at 2022年6月14日 下午7:26:01</p>
137+
</div>
138+
</div>
139+
</body>
140+
</html>

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,28 @@ public static void getJsonSettings(String path, boolean isClasspath, Optilog ins
1313
try {
1414
if (!isClasspath) {
1515
JsonSettingBean bean = new Gson().fromJson(Files.readString(Path.of(path), StandardCharsets.UTF_8), JsonSettingBean.class);
16-
16+
try {
17+
instance.allSetting.printInfo = Boolean.parseBoolean(bean.print.get("info"));
18+
instance.allSetting.printError = Boolean.parseBoolean(bean.print.get("error"));
19+
instance.allSetting.printWarn = Boolean.parseBoolean(bean.print.get("warn"));
20+
instance.allSetting.printDebug = Boolean.parseBoolean(bean.print.get("debug"));
21+
instance.allSetting.printFatal = Boolean.parseBoolean(bean.print.get("fatal"));
22+
} catch (NullPointerException ignored) {
23+
}
24+
25+
try {
26+
instance.allSetting.consoleInfo = Boolean.parseBoolean(bean.file.get("info"));
27+
instance.allSetting.consoleError = Boolean.parseBoolean(bean.file.get("error"));
28+
instance.allSetting.consoleWarn = Boolean.parseBoolean(bean.file.get("warn"));
29+
instance.allSetting.consoleDebug = Boolean.parseBoolean(bean.file.get("debug"));
30+
instance.allSetting.consoleFatal = Boolean.parseBoolean(bean.file.get("fatal"));
31+
String a = bean.file.get("defaultConsolePath");
32+
if (a != null) {
33+
instance.allSetting.defaultConsolePath = bean.file.get("defaultConsolePath").trim();
34+
}
35+
} catch (NullPointerException ignored) {
36+
}
37+
1738
} else {
1839
String content;
1940
}

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

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,16 @@ static void xml(String path, boolean isClasspath, Optilog instance) {
105105
System.err.println("Optilog Note: Failed to read xml setting file!");
106106
instance.consoleFileMasterCaution = false;
107107
e.printStackTrace();
108+
} catch (NullPointerException ignored) {
109+
108110
}
109111
} else {
110112
try (InputStream input = new FileInputStream(path)) {
111113
XmlSettingBean object = new XmlMapper(new JacksonXmlModule()).readValue(input, XmlSettingBean.class);
112114
// config print
113-
if (object.print.get("packingFormat") != null) {
114-
instance.allSetting.printPackingFormat = object.print.get("packingFormat").trim();
115+
String a = object.print.get("packingFormat");
116+
if (a != null) {
117+
instance.allSetting.printPackingFormat = a.trim();
115118
}
116119
instance.allSetting.printInfo = Boolean.parseBoolean(object.print.get("printInfo").trim());
117120
instance.allSetting.printError = Boolean.parseBoolean(object.print.get("printError").trim());
@@ -120,44 +123,57 @@ static void xml(String path, boolean isClasspath, Optilog instance) {
120123
instance.allSetting.printFatal = Boolean.parseBoolean(object.print.get("printFatal").trim());
121124

122125
// config file
123-
if (object.file.get("packingFormat") != null) {
124-
instance.allSetting.consolePackingFormat = object.file.get("packingFormat").trim();
126+
String b = object.file.get("packingFormat");
127+
if (b != null) {
128+
instance.allSetting.consolePackingFormat = b.trim();
125129
}
126-
if (object.file.get("defaultConsolePath") != null) {
127-
instance.allSetting.defaultConsolePath = object.file.get("defaultConsolePath").trim();
130+
String c = object.file.get("defaultConsolePath");
131+
if (c != null) {
132+
instance.allSetting.defaultConsolePath = c.trim();
128133
}
129-
if (object.file.get("Path1") != null) {
130-
instance.allSetting.Path1 = object.file.get("Path1").trim();
134+
String d = object.file.get("Path1");
135+
if (d != null) {
136+
instance.allSetting.Path1 = d.trim();
131137
}
132-
if (object.file.get("Path2") != null) {
133-
instance.allSetting.Path2 = object.file.get("Path2").trim();
138+
String e = object.file.get("Path2");
139+
if (e != null) {
140+
instance.allSetting.Path2 = e.trim();
134141
}
135-
if (object.file.get("Path3") != null) {
136-
instance.allSetting.Path3 = object.file.get("Path3").trim();
142+
String f = object.file.get("Path3");
143+
if (f != null) {
144+
instance.allSetting.Path3 = f.trim();
137145
}
138-
if (object.file.get("Path4") != null) {
139-
instance.allSetting.Path4 = object.file.get("Path4").trim();
146+
String g = object.file.get("Path4");
147+
if (g != null) {
148+
instance.allSetting.Path4 = g.trim();
140149
}
141-
if (object.file.get("Path5") != null) {
142-
instance.allSetting.Path5 = object.file.get("Path5").trim();
150+
String h = object.file.get("Path5");
151+
if (h != null) {
152+
instance.allSetting.Path5 = h.trim();
143153
}
144-
if (object.file.get("infoPath") != null) {
145-
instance.allSetting.infoPath = object.file.get("infoPath").trim();
154+
String i = object.file.get("infoPath");
155+
if (i != null) {
156+
instance.allSetting.infoPath = i.trim();
146157
}
147-
if (object.file.get("errorPath") != null) {
148-
instance.allSetting.errorPath = object.file.get("errorPath").trim();
158+
String j = object.file.get("errorPath");
159+
if (j != null) {
160+
instance.allSetting.errorPath = j.trim();
149161
}
150-
if (object.file.get("warnPath") != null) {
151-
instance.allSetting.warnPath = object.file.get("warnPath").trim();
162+
String k = object.file.get("warnPath");
163+
if (k != null) {
164+
instance.allSetting.warnPath = k.trim();
152165
}
153-
if (object.file.get("debugPath") != null) {
154-
instance.allSetting.debugPath = object.file.get("debugPath").trim();
166+
String l = object.file.get("debugPath");
167+
if (l != null) {
168+
instance.allSetting.debugPath = l.trim();
155169
}
156-
if (object.file.get("fatalPath") != null) {
157-
instance.allSetting.fatalPath = object.file.get("fatalPath").trim();
170+
String m = object.file.get("fatalPath");
171+
if (m != null) {
172+
instance.allSetting.fatalPath = m.trim();
158173
}
159-
if (object.file.get("fileName") != null) {
160-
instance.allSetting.fileName = object.file.get("fileName").trim();
174+
String n = (object.file.get("fileName"));
175+
if (n != null) {
176+
instance.allSetting.fileName = n.trim();
161177
}
162178
instance.allSetting.consoleInfo = Boolean.parseBoolean(object.file.get("consoleInfo").trim());
163179
instance.allSetting.consoleError = Boolean.parseBoolean(object.file.get("consoleError").trim());
@@ -166,25 +182,30 @@ static void xml(String path, boolean isClasspath, Optilog instance) {
166182
instance.allSetting.consoleFatal = Boolean.parseBoolean(object.file.get("consoleFatal").trim());
167183

168184
// config server
169-
if (object.server.get("packingFormat") != null) {
170-
instance.allSetting.serverPackingFormat = object.server.get("packingFormat").trim();
185+
String o = object.server.get("packingFormat");
186+
if (o != null) {
187+
instance.allSetting.serverPackingFormat = o.trim();
171188
}
172189
instance.allSetting.serverInfo = Boolean.parseBoolean(object.server.get("serverInfo").trim());
173190
instance.allSetting.serverError = Boolean.parseBoolean(object.server.get("serverError").trim());
174191
instance.allSetting.serverWarn = Boolean.parseBoolean(object.server.get("serverWarn").trim());
175192
instance.allSetting.serverDebug = Boolean.parseBoolean(object.server.get("serverDebug").trim());
176193
instance.allSetting.serverFatal = Boolean.parseBoolean(object.server.get("serverFatal").trim());
177194
instance.allSetting.startClient = Boolean.parseBoolean(object.server.get("startClient").trim());
178-
if (object.server.get("host") != null) {
179-
instance.allSetting.host = object.server.get("host");
195+
String p = object.server.get("host");
196+
if (p != null) {
197+
instance.allSetting.host = p.trim();
180198
}
181-
if (object.server.get("socketNumber") != null) {
182-
instance.allSetting.socketNumber = Integer.parseInt(object.server.get("socketNumber"));
199+
String q = object.server.get("socketNumber");
200+
if (q != null) {
201+
instance.allSetting.socketNumber = Integer.parseInt(q.trim());
183202
}
184203

185204
} catch (IOException e) {
186205
System.err.println("Optilog Note: Failed to read xml setting file!");
187206
e.printStackTrace();
207+
} catch (NullPointerException ignored) {
208+
188209
}
189210
}
190211
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,5 @@ public static void yaml(String path, boolean isClasspath, Optilog instance) {
135135
}
136136
} catch (NumberFormatException | NullPointerException ignored) {
137137
}
138-
139138
}
140139
}

0 commit comments

Comments
 (0)