package syslog import ( "strings" ) // ParseSyslogLine extracts the message content from a syslog line. // It looks for the daemon prefix in the line and returns the message after it. // // Example input: "Dec 2 02:01:33 tyet daemon.info iwd: Error loading /var/lib/iwd//nemuphone.psk" // Example output: "Error loading /var/lib/iwd//nemuphone.psk", true // // Returns the message and a boolean indicating if the line was successfully parsed. func ParseSyslogLine(line, daemonPrefix string) (string, bool) { // Find the daemon prefix in the line (e.g., "iwd:") idx := strings.Index(line, daemonPrefix) if idx == -1 { return "", false } // Extract everything after the daemon prefix message := line[idx+len(daemonPrefix):] // Trim leading/trailing whitespace message = strings.TrimSpace(message) if message == "" { return "", false } return message, true }