osbase/logtree.LeveledLogger -> go/logging.Leveled

This factors out the common leveled logger interface out of the logtree.
We want to use the same interface outside of logtree/supervisor usage
within the resolver code, which will be exposed to clients.

Change-Id: I299e76d91e8cefddf8f36f1e58432418c4694df2
Reviewed-on: https://review.monogon.dev/c/monogon/+/3411
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/osbase/logtree/leveled_payload.go b/osbase/logtree/leveled_payload.go
index 95b9d5c..b038848 100644
--- a/osbase/logtree/leveled_payload.go
+++ b/osbase/logtree/leveled_payload.go
@@ -24,6 +24,7 @@
 
 	tpb "google.golang.org/protobuf/types/known/timestamppb"
 
+	"source.monogon.dev/go/logging"
 	lpb "source.monogon.dev/osbase/logtree/proto"
 )
 
@@ -38,7 +39,7 @@
 	// timestamp is the time at which this message was emitted.
 	timestamp time.Time
 	// severity is the leveled Severity at which this message was emitted.
-	severity Severity
+	severity logging.Severity
 	// file is the filename of the caller that emitted this message.
 	file string
 	// line is the line number within the file of the caller that emitted this message.
@@ -111,14 +112,14 @@
 func (p *LeveledPayload) Location() string { return fmt.Sprintf("%s:%d", p.file, p.line) }
 
 // Severity returns the Severity with which this entry was logged.
-func (p *LeveledPayload) Severity() Severity { return p.severity }
+func (p *LeveledPayload) Severity() logging.Severity { return p.severity }
 
 // Proto converts a LeveledPayload to protobuf format.
 func (p *LeveledPayload) Proto() *lpb.LogEntry_Leveled {
 	return &lpb.LogEntry_Leveled{
 		Lines:     p.Messages(),
 		Timestamp: tpb.New(p.Timestamp()),
-		Severity:  p.Severity().ToProto(),
+		Severity:  SeverityToProto(p.Severity()),
 		Location:  p.Location(),
 	}
 }
@@ -167,7 +168,7 @@
 	// given, will default to the time of conversion to LeveledPayload.
 	Timestamp time.Time
 	// Log severity. If invalid or unset will default to INFO.
-	Severity Severity
+	Severity logging.Severity
 	// File name of originating code. Defaults to "unknown" if not set.
 	File string
 	// Line in File. Zero indicates the line is not known.
@@ -188,7 +189,7 @@
 		l.timestamp = time.Now()
 	}
 	if !l.severity.Valid() {
-		l.severity = INFO
+		l.severity = logging.INFO
 	}
 	if l.file == "" {
 		l.file = "unknown"