in internal/command/log.go [63:96]
func (r *logRunner) sendLog(path string, out output.Output) error {
logger := r.logger.With("log", path)
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()
var totalBytes, totalLines int
s := bufio.NewScanner(bufio.NewReader(f))
buf := make([]byte, r.out.MaxLogLineSize)
s.Buffer(buf, r.out.MaxLogLineSize)
for s.Scan() {
if r.cmd.Context().Err() != nil {
break
}
logger.Debugw("Sending log line.", "line_number", totalLines+1)
n, err := out.Write(s.Bytes())
if err != nil {
return err
}
totalBytes += n
totalLines++
}
if s.Err() != nil {
return s.Err()
}
logger.Infow("Log data sent.", "total_bytes", totalBytes, "total_lines", totalLines)
return nil
}