aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-05-16 14:06:24 +0200
committerAleksandr Nogikh <wp32pw@gmail.com>2023-05-17 10:50:10 +0200
commite7cfb0155674c36bb8f1ae0951ccf74992848733 (patch)
tree69a9b38a59c057e3199e6b1c2668673c54dc8a99 /pkg
parenteaac4681d47d67269ffba8e824990026bda5eb46 (diff)
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.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/log/log.go17
1 files changed, 11 insertions, 6 deletions
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])