package pkg import "regexp" type ( LogEntries struct { Logs []*Entry `json:"logs"` } Entry struct { Date string `json:"date"` DevName string `json:"device_name"` User string `json:"user"` Command string `json:"command"` } ) func ParseAuditLogs(s string) *LogEntries { l := new(LogEntries) for _, v := range regexp.MustCompile(`\n(\S+ \S+ \S+) (\S+).*user[\s+|=](\S+) .*? (object\s+0\s+-\s+|cmd_data=)(.*?)\n`).FindAllStringSubmatch(s, -1) { if v[3] != "netsec.devops" { l.Logs = append(l.Logs, &Entry{ Date: v[1], DevName: v[2], User: v[3], Command: v[5], }) } } return l }