This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch log_tool
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/log_tool by this push:
new 2713e40 add documentations of log visualizer
2713e40 is described below
commit 2713e403165b543bc1b6d27231a128400beba730
Author: jt <[email protected]>
AuthorDate: Fri Aug 30 17:14:27 2019 +0800
add documentations of log visualizer
---
.../UserGuide/8-System Tools/3-Log Visualizer.md | 135 +++++++++++++++++++
.../UserGuide/8-System Tools/3-Log Visualizer.md | 147 +++++++++++++++++++++
.../{logAnalyze => logVisualize}/config.properties | 0
.../default.log.pattern | 14 +-
.../log-visualizer.bat | 0
.../{logAnalyze => logVisualize}/log-visualizer.sh | 0
.../plans/flushTimeConsumption.plan | 2 +-
.../apache/iotdb/db/tools/logvisual/LogFilter.java | 24 +---
.../iotdb/db/tools/logvisual/PatternLogParser.java | 26 ++--
.../iotdb/db/tools/logvisual/VisualUtils.java | 18 +++
10 files changed, 332 insertions(+), 34 deletions(-)
diff --git a/docs/Documentation-CHN/UserGuide/8-System Tools/3-Log
Visualizer.md b/docs/Documentation-CHN/UserGuide/8-System Tools/3-Log
Visualizer.md
new file mode 100644
index 0000000..185e001
--- /dev/null
+++ b/docs/Documentation-CHN/UserGuide/8-System Tools/3-Log Visualizer.md
@@ -0,0 +1,135 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+
+## 日志可视化工具LogVisualizer
+
+<!-- TOC -->
+
+- [日志可视化工具LogVisualizer](#日志可视化工具LogVisualizer)
+- [介绍](#介绍)
+- [使用方法](#使用方法)
+ - [准备工作](#准备工作)
+ - [启动图形界面](#启动图形界面)
+ - [选择日志文件](#选择日志文件)
+ - [选择解析器配置文件](#选择解析器配置文件)
+ - [载入日志](#载入日志)
+ - [新建可视化计划](#新建可视化计划)
+ - [编辑可视化计划](#编辑可视化计划)
+ - [删除可视化计划](#删除可视化计划)
+ - [执行可视化计划](#执行可视化计划)
+
+
+<!-- /TOC -->
+
+# 介绍
+和其他的众多系统软件一样,IoTDB在运行时会产生大量各种各样的日志。debug和trace级别的日志可以帮助
+开发者掌握IoTDB的运行时状态,找出潜在的或是尚不明确的bug。而info级别的日志可以用来判断系统的健康程度,
+并且可以为系统调优提供一个指导方向。一旦出现warn时甚至error级别的日志,就代表了系统正处于一个危险的
+状态或者是发生了某种异常(往往是某种bug或者黑客攻击),系统管理员可以通过分析这些日志及时对系统调整,
+避免系统走向崩溃,或是在系统崩溃找寻系统崩溃的原因。
+
+鉴于日志对于监控系统的运行状态具有重大意义,许多学术界和工业界的专家都致力于研究如何对日志进行挖崛来
+提取其中的有价值的信息。传统的日志分析需要对系统和日志高度熟悉的人对日志进行有针对性的仔细阅读与分析
+才能发现日志背后的价值。通常,由不同数据源(例如Java中不同的类)产生的日志混合在若干个文件中,只有经验
+丰富的开发或运维人员才能快速地从海量的日志中找到想要的日志,而那些资历尚浅的人则需要花费大量的时间
+阅读和排除无用的日志才能最终找到他们所希望的日志。并且,日志的形式通常是包含了一些系统状态量的字符串,
+对于人类来说,要从这些字符串中发现其背后的趋势显然没有通过图表和统计信息等其他形式来得容易。
+
+为了方便开发和运维人员了解日志背后的系统状态的变化,以及将它们进行对比分析,我们推出了一个简易的日志
+可视化工具LogVisualizer。在用户通过正则表达式指定了日志中他们所感兴趣的变量后,LogVisualizer将自动
+抽取这些变量,按照对应日志的产生时间为这些变量生成时间序列,并以折线图的形式绘制这些变量的变化,以
+方便后续的比较和分析。同时,LogVisualizer还会对这些时间序列进行统计,找出其中的最大值、最小值、平均值、
+日志条数等信息,使得用户能有一个总体性的认识。
+
+# 使用方法
+## 准备工作
+在使用LogVisualizer之前,你需要对其进行构建。LogVisualizer被集成到server模块作为一个系统工具,因此你
+可以通过构建server模块来同时构建LogVisualizer。你可以使用以下命令:
+> mvn clean package -pl server -DskipTests
+
+之后你能在这个目录下找到LogVisualizer的启动脚本:
+`server/target/iotdb-server-{project-version}-SNAPSHOT/tools/logVisualize`
+
+## 启动图形界面
+你可以通过脚本`log-visualizer.sh` (在Windows下为`log-visualizer.bat`)来启动LogVisualizer.
这将会启动
+一个如下图所示的图形界面:
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/main_panel.png?raw=true">
+
+## 选择日志文件
+首先,你需要点击图示的按钮选择一个含有待可视化日志的文件。注意:我们目前仅支持单行日志,多行日志无法
+被正确解析而会被忽略。
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/select_log_file.png?raw=true">
+
+## 选择解析器配置文件
+然后,你还需要选择一个解析器配置文件,该文件将告诉LogVisualizer如何解析日志。对于IoTDB产生的日志,我们在
+`tools\default.log.pattern`里提供了一个例子。如果你需要解析的日志与IoTDB的日志具有相同的格式,你可以
+直接使用该文件。否则,你需要仔细阅读该样例文件,并根据你的日志结构进行相应的修改。
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/select_log_parser_property.png?raw=true">
+
+## 载入日志
+之后,点击`Load logs`按钮来让LogVisualizer准备对这些日志进行解析。如果准备成功,按钮上方将显示
+`Logs are successfully loaded`。否则将会弹出一个对话框提示错误,你需要根据错误内容进行相应处理。
+
+ <img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/load_logs.png?raw=true">
+
+## 加载可视化计划
+接下来,你可以选择加载磁盘上已有的可视化计划或者新建计划。要加载已有的计划,只需要点击 `Load plans`
+按钮,并在弹出的对话框中选择想要加载的计划文件或者包含计划文件的文件夹。注意,如果选择文件夹,该文件
+夹必须只包含计划文件。
+
+ <img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/load_plan.png?raw=true">
+
+## 新建可视化计划
+现在,我们将展示如何使用图形界面创建一个新的可视化计划,你也可以参考已有的计划文件,使用文本编辑器编写。
+首先点击`Create plan`按钮并选择存放新计划的文件,新计划将出现在右边的列表。选择的文件名将作为新计划的
+名称,该名称不能与已有的计划重复。
+
+ <img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/create_plan.png?raw=true">
+
+## 编辑可视化计划
+在创建了一个新的计划以后,你可以在右边的面板中对其进行编辑。我们在
`tools/logVisualize/plans/flushTimeConsumption.plan`
+提供了一个样例来帮助你理解计划的每一个字段的含义以及应该如何设置它们,我们强烈推荐你仔细阅读该样例。
+你也可以编辑其他已经加载了的计划。编辑结束后请务必点击`Save plan`按钮来保存您的修改。在下图的例子中,
+我们给出了如何设计一个计划让它能对任务的完成时间进行可视化,并将任务按照其类别进行分组。
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/edit_plan.png?raw=true">
+
+## 删除可视化计划
+如果你不再想使用某个计划,你可以选中它并点击`Delete plan`按钮。这将永久地把该计划从磁盘上移除。
+
+## 执行可视化计划
+最后,选中一个计划并点击`Execute plan`就可以执行该计划。请确保你之前已经加载了日志。计划执行以后,
+主界面上将会多出两个页面,第一个页面包含了若干个时间序列图,每一个对应了计划里的一个分组并且包含了
+计划中的所有测点(measurement),第二个页面包含了对每一组的日志的每个测点的统计信息。当你结束对一个
+页面的浏览以后,你可以点击页面右上角的按钮将其关闭。
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/execute_plan.png?raw=true">
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/plot.png?raw=true">
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/statistics.png?raw=true">
+
+
+
diff --git a/docs/Documentation/UserGuide/8-System Tools/3-Log Visualizer.md
b/docs/Documentation/UserGuide/8-System Tools/3-Log Visualizer.md
new file mode 100644
index 0000000..5fcfbca
--- /dev/null
+++ b/docs/Documentation/UserGuide/8-System Tools/3-Log Visualizer.md
@@ -0,0 +1,147 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+# Chapter 8: System Tools
+
+## LogVisualizer
+
+<!-- TOC -->
+
+- [LogVisualizer](#LogVisualizer)
+- [Introduction](#introduction)
+- [Usage](#Usage)
+ - [Preparation](#preparation)
+ - [Run the gui](#Run the gui)
+ - [Choose a log file](#Choose a log file)
+ - [Choose a parser property file](#Choose a parser property file)
+ - [Load logs](#Load logs)
+ - [Create new plans](#Create new plans)
+ - [Edit plans](#Edit plans)
+ - [Delete plans](#Delete plans)
+ - [Execute plans](#Execute plans)
+
+
+<!-- /TOC -->
+
+# Introduction
+IoTDB generates a variety of logs during runtime like other software systems.
The debug and trace
+logs can help the developers keep trace of the status of IoTDB and dig
potential or unclear bugs
+The info logs may tell how healthy the system is and provide directions for
database parameter
+optimization. The warn and error logs indicates the system is in a dangerous
status or
+something unexpected happened (very likely a bug or an attack) and helps the
database
+administrator save the system before it crashes or find the reasons why it has
crashed.
+
+With the logs being so valuable a source of monitoring system status, mining
the logs for their
+potential precious information has become quite a hot issue both in academy
and industry.
+Traditional ways often require much human-resource to discovery the value
behind the logs by
+reading and analyzing the logs carefully. Usually, the logs of different
sources (like Java
+classes) are mixed together in several files and only the most experienced
debugging experts know
+from the beginning what logs exactly they long for, many less experienced
programmers would spend
+time reading unrelated logs and filtering them out. Nevertheless, logs are
most composed with string
+containing numbers which describe the system status and they are much less
straight-forward for
+humans to understand and compare than plots and statistics.
+
+To relieve the hardness of understanding what has happened behind these logs
and better comparing
+them, we present a simple tool LogVisualizer to retrieve interesting
(specified by the user)
+variants in a log file, generate timeseries based on these observations and
draw plots to show
+them in a more human-friendly way. LogVisualizer also collects the statistics
of the logs to
+present an overall view of what was going on.
+
+# Usage
+## Preparation
+Before using LogVisualizer, you should have it built. Since LogVisualizer is
integrated in the
+server module as a tool, you can build the server together with LogVisualizer
using:
+> mvn clean package -pl server -DskipTests
+
+Then you fan find the scripts to start LogVisualizer in:
+`server/target/iotdb-server-{project-version}-SNAPSHOT/tools/logVisualize`
+
+## Run the gui
+You can run LogVisualizer using `log-visualizer.sh` (or `log-visualizer.bat`
in windows). This
+will bring you a gui like:
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/main_panel.png?raw=true">
+
+## Choose a log file
+First, you should choose a file containing the logs to be visualized. Notice
that we currently
+only support single-line logs and logs with multiple lines will be ignored.
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/select_log_file.png?raw=true">
+
+## Choose a parser property file
+Second, you should also choose a file describing how to parse the log file.
For log files
+produced by IoTDB, we provide an example in `tools\default.log.pattern`. If
your logs have
+similar structure as the IoTDB ones, you may just use it, otherwise, you
should read that file
+carefully and modify it for your logs.
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/select_log_parser_property.png?raw=true">
+
+## Load logs
+Then, click the `Load logs` button to let the LogVisualizer to prepare to read
the logs. If the
+preparation is successful, the label above will show `Logs are successfully
loaded`, otherwise, a
+dialog will show you what has gone wrong and you should fix it accordingly.
+
+ <img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/load_logs.png?raw=true">
+
+## Load plans
+Next, you can load existing visualization plans or create new ones. For
loading existing plans,
+just click the button `Load plans` and choose the log files or directories
that contain log
+files. Notice that if choose directory, then the directory must only contain
visualization plans.
+
+ <img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/load_plan.png?raw=true">
+
+## Create new plans
+Now, we will present an example of how to create a new plan. First, click the
`Create plan`
+button and choose a place to save the new plan, then the plan will show up in
the list in the
+left. The name of the file will be used as the plan's name and it must not be
different from
+any existing plans.
+
+ <img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/create_plan.png?raw=true">
+
+## Edit plans
+After creating the new plan, you can edit it in the right panel. We provide an
example in
+ `tools/logVisualize/plans/flushTimeConsumption.plan`, we strongly recommend
you read it
+carefully to know how to fill the fields. You can also edit plans you have
loaded here. Do not
+forget to click the `Save plan` button if you want to save what you have
modified.If you
+want to create a plan that show the time consumptions of jobs grouped by their
type, you may set
+the fields like the following one.
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/edit_plan.png?raw=true">
+
+## Delete plans
+If you don't want a plan anymore, you can select it and click `Delete plan`
button. This will
+remove the plan from the disk.
+
+## Execute plans
+Finally, you can execute a plan by selecting it and click `Execute plan`.
Please make sure you
+have loaded the logs. Afterwards, two tabs will be added into the main panel.
The first contains
+timeseries charts each corresponding to log groups and plotting the
measurements specified by the
+plan. The second one presents the statistics of each log group. Once you have
done browsing, you
+can click the button on the up-right to close the tab.
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/execute_plan.png?raw=true">
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/plot.png?raw=true">
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto;
margin-right:auto; display:block;"
src="https://github.com/jt2594838/PicHub/blob/master/log-visualizer/statistics.png?raw=true">
+
+
+
diff --git a/server/src/assembly/resources/tools/logAnalyze/config.properties
b/server/src/assembly/resources/tools/logVisualize/config.properties
similarity index 100%
rename from server/src/assembly/resources/tools/logAnalyze/config.properties
rename to server/src/assembly/resources/tools/logVisualize/config.properties
diff --git a/server/src/assembly/resources/tools/logAnalyze/default.log.pattern
b/server/src/assembly/resources/tools/logVisualize/default.log.pattern
similarity index 74%
rename from server/src/assembly/resources/tools/logAnalyze/default.log.pattern
rename to server/src/assembly/resources/tools/logVisualize/default.log.pattern
index 57fdf42..1f808fe 100644
--- a/server/src/assembly/resources/tools/logAnalyze/default.log.pattern
+++ b/server/src/assembly/resources/tools/logVisualize/default.log.pattern
@@ -17,20 +17,26 @@
# under the License.
#
-# Pattern defines how a log looks like. A log must be exactly one line.
+# an example that this pattern matches:
+# "2019-08-22 00:00:00,898 [pool-4-IoTDB-Flush-ServerServiceImpl-thread-2] INFO
+# org.apache.iotdb.db.engine.flush.MemTableFlushTask:95 - Storage group
root.perform.group_14 memtable
+# org.apache.iotdb.db.engine.memtable.PrimitiveMemTable@34f flushing a
memtable has finished!
+# Time consumption: 7756ms"
+
+# A regular expression defines how a log looks like. A log must be exactly one
line.
pattern=([^\\[]*)(\\[.*])(\\s\\w+\\s)([^:]*:\\d+)(\\s-\\s)(.*)
# The index of the group which represents the date that the log is generated,
one based
date_index=1
# How the date is formatted
date_pattern=yyyy-MM-dd hh:mm:ss,SSS
-# The index of the group which represents the thread name, one based
+# The index of the group which represents the thread name, one based, optional
thread_name_index=2
-# The index of the group which represents the log level, one based
+# The index of the group which represents the log level, one based, optional
level_index=3
# The index of the group which represents the position of the code (class name
and line number)
# that generated the log, one based
code_location_index=4
-# The index of the group which represents the message in the log, one based
+# The index of the group which represents the message in the log, one based,
optional
content_index=6
diff --git a/server/src/assembly/resources/tools/logAnalyze/log-visualizer.bat
b/server/src/assembly/resources/tools/logVisualize/log-visualizer.bat
similarity index 100%
rename from server/src/assembly/resources/tools/logAnalyze/log-visualizer.bat
rename to server/src/assembly/resources/tools/logVisualize/log-visualizer.bat
diff --git a/server/src/assembly/resources/tools/logAnalyze/log-visualizer.sh
b/server/src/assembly/resources/tools/logVisualize/log-visualizer.sh
similarity index 100%
rename from server/src/assembly/resources/tools/logAnalyze/log-visualizer.sh
rename to server/src/assembly/resources/tools/logVisualize/log-visualizer.sh
diff --git
a/server/src/assembly/resources/tools/logAnalyze/plans/flushTimeConsumption.plan
b/server/src/assembly/resources/tools/logVisualize/plans/flushTimeConsumption.plan
similarity index 93%
rename from
server/src/assembly/resources/tools/logAnalyze/plans/flushTimeConsumption.plan
rename to
server/src/assembly/resources/tools/logVisualize/plans/flushTimeConsumption.plan
index d88232d..779c1d1 100644
---
a/server/src/assembly/resources/tools/logAnalyze/plans/flushTimeConsumption.plan
+++
b/server/src/assembly/resources/tools/logVisualize/plans/flushTimeConsumption.plan
@@ -19,7 +19,7 @@
# the name of the this plan
name=flushTimeConsumption
-# how are the targeted logs formatted and what fields are interesting and
should be grouped
+# a regular expression that defines how are the targeted logs formatted and
what fields are interesting and should be grouped
content_pattern=Storage group (.*) memtable (.*) flushing a memtable has
finished! Time consumption: (.*)ms
# the following 3 properties are all one-based, if there are more than one
measurements or tags, use
diff --git
a/server/src/main/java/org/apache/iotdb/db/tools/logvisual/LogFilter.java
b/server/src/main/java/org/apache/iotdb/db/tools/logvisual/LogFilter.java
index 4da8d15..88d4ca3 100644
--- a/server/src/main/java/org/apache/iotdb/db/tools/logvisual/LogFilter.java
+++ b/server/src/main/java/org/apache/iotdb/db/tools/logvisual/LogFilter.java
@@ -82,10 +82,10 @@ public class LogFilter {
public FilterFeedBack filter(LogEntry entry) {
if (entry.getLogLevel().ordinal() < minLevel.ordinal() ||
- (threadNameWhiteList != null && !strsContains(threadNameWhiteList,
entry.getThreadName())) ||
- (classNameWhiteList != null && !strsContains(classNameWhiteList,
entry.getCodeLocation()
+ (threadNameWhiteList != null &&
!VisualUtils.strsContains(threadNameWhiteList, entry.getThreadName())) ||
+ (classNameWhiteList != null &&
!VisualUtils.strsContains(classNameWhiteList, entry.getCodeLocation()
.getClassName())) ||
- (lineNumWhiteList != null && !intsContains(lineNumWhiteList,
entry.getCodeLocation()
+ (lineNumWhiteList != null &&
!VisualUtils.intsContains(lineNumWhiteList, entry.getCodeLocation()
.getLineNum())) ||
(startDate != null && entry.getDate().before(startDate))) {
return FilterFeedBack.REJECT;
@@ -97,24 +97,6 @@ public class LogFilter {
return FilterFeedBack.OK;
}
- private boolean strsContains(String[] strings, String target) {
- for (String str : strings) {
- if (str.equals(target)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean intsContains(int[] ints, int target) {
- for (int i : ints) {
- if (i == target) {
- return true;
- }
- }
- return false;
- }
-
public LogLevel getMinLevel() {
return minLevel;
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/tools/logvisual/PatternLogParser.java
b/server/src/main/java/org/apache/iotdb/db/tools/logvisual/PatternLogParser.java
index 47a714a..3d299f1 100644
---
a/server/src/main/java/org/apache/iotdb/db/tools/logvisual/PatternLogParser.java
+++
b/server/src/main/java/org/apache/iotdb/db/tools/logvisual/PatternLogParser.java
@@ -54,10 +54,11 @@ public class PatternLogParser implements LogParser{
this.pattern =
Pattern.compile(properties.getProperty(PATTERN.getPropertyName()));
this.dateIndex =
Integer.parseInt(properties.getProperty(DATE_INDEX.getPropertyName()));
this.threadNameIndex =
Integer.parseInt(properties.getProperty(THREAD_NAME_INDEX
- .getPropertyName()));
- this.levelIndex =
Integer.parseInt(properties.getProperty(LEVEL_INDEX.getPropertyName()));
+ .getPropertyName(), String.valueOf(-1)));
+ this.levelIndex =
Integer.parseInt(properties.getProperty(LEVEL_INDEX.getPropertyName(),
+ String.valueOf(-1)));
this.codeLocationIndex =
Integer.parseInt(properties.getProperty(CODE_LOCATION_INDEX
- .getPropertyName()));
+ .getPropertyName(), String.valueOf(-1)));
this.contentIndex =
Integer.parseInt(properties.getProperty(CONTENT_INDEX.getPropertyName()));
this.dateFormat = new
SimpleDateFormat(properties.getProperty(DATE_PATTERN.getPropertyName()));
this.logFilePath = logFilePath;
@@ -82,11 +83,20 @@ public class PatternLogParser implements LogParser{
logger.error("Incorrect time format in {}", e);
return null;
}
- String threadName = matcher.group(threadNameIndex).trim();
- LogLevel logLevel = LogLevel.valueOf(matcher.group(levelIndex).trim());
- String[] codeLocationStr = matcher.group(codeLocationIndex).split(":");
- CodeLocation codeLocation = new CodeLocation(codeLocationStr[0].trim(),
Integer.parseInt
- (codeLocationStr[1]));
+ String threadName = null;
+ if (threadNameIndex > 0) {
+ threadName = matcher.group(threadNameIndex).trim();
+ }
+ LogLevel logLevel = LogLevel.DEBUG;
+ if (levelIndex > 0) {
+ logLevel = LogLevel.valueOf(matcher.group(levelIndex).trim());
+ }
+ CodeLocation codeLocation = null;
+ if (codeLocationIndex > 0) {
+ String[] codeLocationStr = matcher.group(codeLocationIndex).split(":");
+ codeLocation = new CodeLocation(codeLocationStr[0].trim(),
Integer.parseInt
+ (codeLocationStr[1]));
+ }
String content = matcher.group(contentIndex).trim();
return new LogEntry(date, threadName, logLevel, codeLocation, content);
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/tools/logvisual/VisualUtils.java
b/server/src/main/java/org/apache/iotdb/db/tools/logvisual/VisualUtils.java
index 0f61d5e..ab0d3fe 100644
--- a/server/src/main/java/org/apache/iotdb/db/tools/logvisual/VisualUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/tools/logvisual/VisualUtils.java
@@ -47,4 +47,22 @@ public class VisualUtils {
}
return builder.toString();
}
+
+ public static boolean strsContains(String[] strings, String target) {
+ for (String str : strings) {
+ if (str.equals(target)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean intsContains(int[] ints, int target) {
+ for (int i : ints) {
+ if (i == target) {
+ return true;
+ }
+ }
+ return false;
+ }
}
\ No newline at end of file