/// <summary> /// logcat /// </summary> /// <param name="pid">进程id</param> /// <param name="level">日志级别</param> /// <param name="searchStr">搜索字符串</param> /// <param name="outputDataReceived">output回调</param> /// <param name="errorDataReceived">error回调</param> public void Logcat(int pid, int level, DataReceivedEventHandler outputDataReceived, DataReceivedEventHandler errorDataReceived, string searchStr = "") { CmdHelper.KillAsyncProcess(); Thread.Sleep(200); string[] levelInfo = new string[] { "V", "D", "I", "W", "E", "F", "S" }; string pidCmd = ""; string levelCmd = ""; string searchCmd = ""; if (pid > 0) { pidCmd = " |findstr \"" + pid.ToString() + "\""; } if (level >= 0) { levelCmd = " *:" + levelInfo[level]; } if (!string.IsNullOrWhiteSpace(searchStr)) { searchCmd = " |findstr " + "\"" + searchStr + "\""; } List <string> Cmds = new List <string>() { $"adb logcat -c", $"adb logcat -v time" + levelCmd + pidCmd + searchCmd }; ExecCmdAsync(Cmds, outputDataReceived, errorDataReceived); }
/// <summary> /// 停止异步的proces /// </summary> public void StopAsyncProcess() { CmdHelper.KillAsyncProcess(); }