findAgentOutputFile searches for a file named agent_output.json within the logDir tree. Returns the first path found (depth-first) and a boolean indicating success.
(logDir string)
| 92 | // findAgentOutputFile searches for a file named agent_output.json within the logDir tree. |
| 93 | // Returns the first path found (depth-first) and a boolean indicating success. |
| 94 | func findAgentOutputFile(logDir string) (string, bool) { |
| 95 | var foundPath string |
| 96 | if walkErr := filepath.Walk(logDir, func(path string, info os.FileInfo, err error) error { |
| 97 | if err != nil { |
| 98 | logsUtilsLog.Printf("walk error at %s: %v", path, err) |
| 99 | return nil |
| 100 | } |
| 101 | if info == nil { |
| 102 | return nil |
| 103 | } |
| 104 | if !info.IsDir() && strings.EqualFold(info.Name(), constants.AgentOutputArtifactName) { |
| 105 | foundPath = path |
| 106 | return errWalkStop |
| 107 | } |
| 108 | return nil |
| 109 | }); walkErr != nil && !errors.Is(walkErr, errWalkStop) { |
| 110 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("filesystem error walking %s: %v", logDir, walkErr))) |
| 111 | } |
| 112 | if foundPath == "" { |
| 113 | return "", false |
| 114 | } |
| 115 | return foundPath, true |
| 116 | } |
| 117 | |
| 118 | // findAgentLogFile searches for agent logs within the logDir. |
| 119 | // It uses engine.GetLogFileForParsing() to determine which log file to use: |
no test coverage detected