convert k8s.io/kubernetes/pkg/proxy to contextual logging, part 1
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
This commit is contained in:
@@ -19,6 +19,9 @@ package util
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
)
|
||||
|
||||
// LineBuffer is an interface for writing lines of input to a bytes.Buffer
|
||||
@@ -46,6 +49,8 @@ type LineBuffer interface {
|
||||
Lines() int
|
||||
}
|
||||
|
||||
var _ logr.Marshaler = &realLineBuffer{}
|
||||
|
||||
type realLineBuffer struct {
|
||||
b bytes.Buffer
|
||||
lines int
|
||||
@@ -108,6 +113,11 @@ func (buf *realLineBuffer) Lines() int {
|
||||
return buf.lines
|
||||
}
|
||||
|
||||
// Implements the logs.Marshaler interface
|
||||
func (buf *realLineBuffer) MarshalLog() any {
|
||||
return strings.Split(buf.b.String(), "\n")
|
||||
}
|
||||
|
||||
type discardLineBuffer struct {
|
||||
lines int
|
||||
}
|
||||
|
Reference in New Issue
Block a user