# logAnalyse **Repository Path**: HCl8/log-analyse ## Basic Information - **Project Name**: logAnalyse - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-06 - **Last Updated**: 2021-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 配置文件说明 > 项目地址:https://git.n.xiaomi.com/yanghualin1/log-analyse ### LineDesc linedesc是描述一行字符串是否匹配,有子串,子串列表,字符串三个模式 #### 子串 子串就只有两个属性 + desc是子字符串,如果字符串中包含desc就可以匹配 + followPre:默认是false,表示是否紧跟上一行log ```json { "desc": "LiteCryptWsClient - connectBlocking", "followPre": true } ``` #### 子串列表 + desc:一个字符串列表,和子串一样,字符串包含就可以匹配 + Relation:`and`和`or`可选,默认是or,and表示一个字符串要包含所有子串才可以匹配,or表示只需要包含一个子串就能匹配 ```json { "desc": [ "handleAsrOnPartialTimeout", "didn't recv resp", "errmsg", "authorizationTokens is null", "scopeResult error1", "ailed to connect to" ], "Relation": "or", "followPre": false } ``` #### 正则表达式 + desc:正则表达式,用正则表达式匹配 + variable:正则表达式中可以返回的变量,key是变量名,value是变量的group位置 + type:固定为`regex` ```json { "desc": ".*LiteCryptXMDClient - postXMDEvent:sequenceId=(\\d*).*size=(\\d*).*", "variable": { "id": 1, "size": 2 }, "type": "regex", "followPre": false } ``` ### logPath + pathFilter:匹配文件夹和压缩包里中需要处理的log + logFilter:可选,对log分析之前进行过滤,比如SDK的log可以使用子串的LineDesc,desc是AIVS ``` { "pathFilter": LineDesc, "logFilter": LineDesc } ``` ### events + lines:LineDesc的列表,表示需要匹配的log串 + crossEvent:默认是false,表示是否会有多个相同类型的event一起交错出现。 + 如果为true,则LineDesc必须是正则表达式,多个LineDesc之间需要有相同的variable来联系起来。 1. send message id:xxx message: LineDesc:`"desc": ".*send message id:(.*) message.*","variable":{"id":1}` 2. channel send package id:xxx len: LineDesc:`"desc": ".*channel send package id:(.*) len:.*", "variable": {"id":1}` 3. send xxx fail LineDesc:`"desc": ".*send (.*) fail.*", variable:{"id":1}` 这三行log中,xxx的部分必须相同,正则中应该把xxx标记为同一个变量id + 如果某个LineDesc实在没有可以表示的变量,则FolloPre需要为true,表示紧跟在匹配到的log后面再被匹配,则可以接受 1. send message id:xxx message: LineDesc:`"desc": ".*send message id:(.*) message.*","variable":{"id":1}` 2. channel send package id:xxx len: LineDesc:`"desc": ".*channel send package id:(.*) len:.*", "variable": {"id":1}` 3. send fail LineDesc:`"desc": "send fail", followPre: true` 这三行log中,第3个log并没有id信息,则第三个必须紧跟在第二个后面(3的followPre必须为true),可以作为同一个event + summary:对event的总结,可以使用所有LineDesc中的变量 + level:有`info`,`debug`,`warn`,`error`可选,不同的level输出的颜色不同 ```json { "lines": [LineDesc], "crossEvent": true, "summary": { "desc": "xmd发送event失败 包大小{1} 序列号{0}", "formatVar": [ "id", "size" ] }, "level": "error" } ``` ### 举例 ```json "xmd post event error": { "lines": [ { "desc": ".*XMDChannel - postEvent.*,(\\d*)", "variable": { "id": 1 }, "type": "regex" }, { "desc": ".*LiteCryptXMDClient - postXMDEvent:sequenceId=(\\d*).*size=(\\d*).*", "variable": { "id": 1, "size": 2 }, "type": "regex" }, { "desc": ".*LiteCryptXMDClient.*onError.*msg=(\\d*).*", "variable": { "id": 1 }, "type": "regex" }, { "desc": ".*XMDChannel.*onError.*msg=(\\d*).*", "variable": { "id": 1 }, "type": "regex" } ], "crossEvent": true, "summary": { "desc": "xmd发送event失败 包大小{1} 序列号{0}", "formatVar": [ "id", "size" ] }, "level": "error" } ``` 匹配输出 ``` xmd发送event失败 包大小9107 序列号1000074 22155 4357 - 08-20 18:23:47.517 - I/SDK [AIVS 4357-UploadThread] XMDChannel - postEvent: General.ContextUpdate,f5001242f964492fb5a8f8477185cdb2,1000074 22155 4357 - 08-20 18:23:47.518 - I/SDK [AIVS 4357-UploadThread] LiteCryptXMDClient - postXMDEvent:sequenceId=1000074, groupId=4, packetId=4, size=9107, connId=33326091560845900 22155 4751 - 08-20 18:23:51.044 - E/SDK [AIVS 4751-Thread-92] LiteCryptXMDClient - onError code=99999, msg=1000074 22155 4751 - 08-20 18:23:51.044 - E/SDK [AIVS 4751-Thread-92] XMDChannel - onError: code=99999, msg=1000074 ``` ## UI界面 ### 菜单栏-文件 打开文件:打开一个zip,文本文件,进行log分析 打开文件夹:在界面左上角打开文件夹并监听该文件夹,双击会分析该文件夹里的文件 打开配置文件:设置配置文件,默认是`logconfig.json` ### 左下事件列表 log分析识别到的事件,单击该事件则会隐藏该事件,双击只显示该事件