diff --git a/src/shim/go.mod b/src/shim/go.mod index e074c357..a83124ef 100644 --- a/src/shim/go.mod +++ b/src/shim/go.mod @@ -13,7 +13,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/opencontainers/runtime-spec v1.1.0-rc.2 github.com/prashantv/gostub v1.1.0 - github.com/sirupsen/logrus v1.9.1 + github.com/sirupsen/logrus v1.9.2 github.com/stretchr/testify v1.8.2 golang.org/x/sys v0.8.0 google.golang.org/grpc v1.55.0 diff --git a/src/shim/go.sum b/src/shim/go.sum index b8da6db5..9468def2 100644 --- a/src/shim/go.sum +++ b/src/shim/go.sum @@ -547,8 +547,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.1 h1:Ou41VVR3nMWWmTiEUnj0OlsgOSCUFgsPAOl6jRIcVtQ= -github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= +github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= diff --git a/src/shim/vendor/github.com/sirupsen/logrus/writer.go b/src/shim/vendor/github.com/sirupsen/logrus/writer.go index 7e7703c7..72e8e3a1 100644 --- a/src/shim/vendor/github.com/sirupsen/logrus/writer.go +++ b/src/shim/vendor/github.com/sirupsen/logrus/writer.go @@ -4,7 +4,6 @@ import ( "bufio" "io" "runtime" - "strings" ) // Writer at INFO level. See WriterLevel for details. @@ -21,18 +20,15 @@ func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { return NewEntry(logger).WriterLevel(level) } -// Writer returns an io.Writer that writes to the logger at the info log level func (entry *Entry) Writer() *io.PipeWriter { return entry.WriterLevel(InfoLevel) } -// WriterLevel returns an io.Writer that writes to the logger at the given log level func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { reader, writer := io.Pipe() var printFunc func(args ...interface{}) - // Determine which log function to use based on the specified log level switch level { case TraceLevel: printFunc = entry.Trace @@ -52,51 +48,23 @@ func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { printFunc = entry.Print } - // Start a new goroutine to scan the input and write it to the logger using the specified print function. - // It splits the input into chunks of up to 64KB to avoid buffer overflows. go entry.writerScanner(reader, printFunc) - - // Set a finalizer function to close the writer when it is garbage collected runtime.SetFinalizer(writer, writerFinalizer) return writer } -// writerScanner scans the input from the reader and writes it to the logger func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { scanner := bufio.NewScanner(reader) - - // Set the buffer size to the maximum token size to avoid buffer overflows - scanner.Buffer(make([]byte, bufio.MaxScanTokenSize), bufio.MaxScanTokenSize) - - // Define a split function to split the input into chunks of up to 64KB - chunkSize := 64 * 1024 // 64KB - splitFunc := func(data []byte, atEOF bool) (int, []byte, error) { - if len(data) > chunkSize { - return chunkSize, data[:chunkSize], nil - } - - return len(data), data, nil - } - - //Use the custom split function to split the input - scanner.Split(splitFunc) - - // Scan the input and write it to the logger using the specified print function for scanner.Scan() { - printFunc(strings.TrimRight(scanner.Text(), "\r\n")) + printFunc(scanner.Text()) } - - // If there was an error while scanning the input, log an error if err := scanner.Err(); err != nil { entry.Errorf("Error while reading from Writer: %s", err) } - - // Close the reader when we are done reader.Close() } -// WriterFinalizer is a finalizer function that closes then given writer when it is garbage collected func writerFinalizer(writer *io.PipeWriter) { writer.Close() } diff --git a/src/shim/vendor/modules.txt b/src/shim/vendor/modules.txt index f9586f24..9df787a0 100644 --- a/src/shim/vendor/modules.txt +++ b/src/shim/vendor/modules.txt @@ -161,7 +161,7 @@ github.com/pmezard/go-difflib/difflib # github.com/prashantv/gostub v1.1.0 ## explicit; go 1.17 github.com/prashantv/gostub -# github.com/sirupsen/logrus v1.9.1 +# github.com/sirupsen/logrus v1.9.2 ## explicit; go 1.13 github.com/sirupsen/logrus # github.com/stretchr/testify v1.8.2