MCPcopy
hub / github.com/nextdns/nextdns / parseWindowsEventText

Function parseWindowsEventText

host/log_windows.go:166–203  ·  view source on GitHub ↗
(out string)

Source from the content-addressed store, hash-verified

164}
165
166func parseWindowsEventText(out string) []windowsEvent {
167 var blocks []string
168 var current []string
169 for _, line := range strings.Split(out, "\n") {
170 line = strings.TrimRight(line, "\r")
171 if strings.HasPrefix(line, "Event[") && strings.HasSuffix(line, "]:") {
172 if len(current) > 0 {
173 blocks = append(blocks, strings.TrimSpace(strings.Join(current, "\n")))
174 }
175 current = []string{line}
176 continue
177 }
178 if len(current) > 0 {
179 current = append(current, line)
180 }
181 }
182 if len(current) > 0 {
183 blocks = append(blocks, strings.TrimSpace(strings.Join(current, "\n")))
184 }
185
186 events := make([]windowsEvent, 0, len(blocks))
187 for _, block := range blocks {
188 e := windowsEvent{Text: block}
189 for _, line := range strings.Split(block, "\n") {
190 line = strings.TrimSpace(line)
191 if !strings.HasPrefix(line, "Event Record ID:") {
192 continue
193 }
194 id, err := strconv.ParseUint(strings.TrimSpace(strings.TrimPrefix(line, "Event Record ID:")), 10, 64)
195 if err == nil {
196 e.RecordID = id
197 }
198 break
199 }
200 events = append(events, e)
201 }
202 return events
203}

Callers 1

queryWindowsEventsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…