From e7cfb0155674c36bb8f1ae0951ccf74992848733 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 16 May 2023 14:06:24 +0200 Subject: pkg/log: adjust fatal errors to the new format Separate SYZFATAL errors (used by syz-fuzzer) and FATAL errors (used by syz-ci and syz-manager). For the latter, use the new logging format. This should facilitate automated error collection. --- pkg/log/log.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'pkg') diff --git a/pkg/log/log.go b/pkg/log/log.go index aee63e6e2..f8a292320 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -73,22 +73,27 @@ func V(level int) bool { } func Logf(v int, msg string, args ...interface{}) { - writeMessage(v, "", msg, args...) + writeMessage(v, message("", msg, args...)) } func Errorf(msg string, args ...interface{}) { - writeMessage(0, "ERROR", msg, args...) + writeMessage(0, message("ERROR", msg, args...)) } func Fatal(err error) { - golog.Fatal("SYZFATAL: ", err) + Fatalf("%v", err) } func Fatalf(msg string, args ...interface{}) { + golog.Fatalf(message("FATAL", msg, args...)) +} + +// SyzFatalf-reported errors are parsed by syzkaller as if they were kernel bugs. +func SyzFatalf(msg string, args ...interface{}) { golog.Fatalf("SYZFATAL: "+msg, args...) } -func writeMessage(v int, severity, msg string, args ...interface{}) { +func message(severity, msg string, args ...interface{}) string { var sb strings.Builder if severity != "" { fmt.Fprintf(&sb, "[%s] ", severity) @@ -97,10 +102,10 @@ func writeMessage(v int, severity, msg string, args ...interface{}) { fmt.Fprintf(&sb, "%s: ", instanceName) } fmt.Fprintf(&sb, msg, args...) - writeRawMessage(v, sb.String()) + return sb.String() } -func writeRawMessage(v int, msg string) { +func writeMessage(v int, msg string) { mu.Lock() if cacheEntries != nil && v <= 1 { cacheMem -= len(cacheEntries[cachePos]) -- cgit mrf-deployment