mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-11-03 21:52:25 -06:00 
			
		
		
		
	[chore]: Bump github.com/minio/minio-go/v7 from 7.0.60 to 7.0.61 (#2041)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
		
					parent
					
						
							
								b874e9251e
							
						
					
				
			
			
				commit
				
					
						9ed9d96597
					
				
			
		
					 34 changed files with 510 additions and 748 deletions
				
			
		
							
								
								
									
										36
									
								
								vendor/github.com/sirupsen/logrus/writer.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								vendor/github.com/sirupsen/logrus/writer.go
									
										
									
										generated
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -4,6 +4,7 @@ import (
 | 
			
		|||
	"bufio"
 | 
			
		||||
	"io"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Writer at INFO level. See WriterLevel for details.
 | 
			
		||||
| 
						 | 
				
			
			@ -20,15 +21,18 @@ 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
 | 
			
		||||
| 
						 | 
				
			
			@ -48,23 +52,51 @@ 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)
 | 
			
		||||
	for scanner.Scan() {
 | 
			
		||||
		printFunc(scanner.Text())
 | 
			
		||||
 | 
			
		||||
	// 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 := bufio.MaxScanTokenSize // 64KB
 | 
			
		||||
	splitFunc := func(data []byte, atEOF bool) (int, []byte, error) {
 | 
			
		||||
		if len(data) >= chunkSize {
 | 
			
		||||
			return chunkSize, data[:chunkSize], nil
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return bufio.ScanLines(data, atEOF)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 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"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 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()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue