system/dbus: print incomplete string in buffer
All checks were successful
Test / Create distribution (push) Successful in 1m8s
Test / Sandbox (push) Successful in 3m43s
Test / Hakurei (push) Successful in 5m27s
Test / Sandbox (race detector) (push) Successful in 6m17s
Test / Hpkg (push) Successful in 7m36s
Test / Hakurei (race detector) (push) Successful in 7m44s
Test / Flake checks (push) Successful in 2m29s
All checks were successful
Test / Create distribution (push) Successful in 1m8s
Test / Sandbox (push) Successful in 3m43s
Test / Hakurei (push) Successful in 5m27s
Test / Sandbox (race detector) (push) Successful in 6m17s
Test / Hpkg (push) Successful in 7m36s
Test / Hakurei (race detector) (push) Successful in 7m44s
Test / Flake checks (push) Successful in 2m29s
Not sure if this will ever be reached, but nice to have nonetheless. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
@@ -170,9 +169,11 @@ func (s *linePrefixWriter) write(p []byte, a int) (int, error) {
|
||||
return a + n, nil
|
||||
} else {
|
||||
n, _ := s.buf.Write(p[:i])
|
||||
s.n += n + 1
|
||||
|
||||
v := s.buf.String()
|
||||
if strings.HasPrefix(v, "init: ") {
|
||||
s.n -= len(v) + 1
|
||||
// pass through container init messages
|
||||
s.println(s.prefix + v)
|
||||
} else {
|
||||
@@ -180,22 +181,20 @@ func (s *linePrefixWriter) write(p []byte, a int) (int, error) {
|
||||
}
|
||||
|
||||
s.buf.Reset()
|
||||
s.n += n + 1
|
||||
return s.write(p[i+1:], a+n+1)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *linePrefixWriter) Dump() {
|
||||
s.mu.RLock()
|
||||
// the final write might go past the threshold,
|
||||
// and the buffer might still contain data
|
||||
var n int
|
||||
for _, m := range s.msg {
|
||||
n += len(m)
|
||||
s.println(s.prefix + m)
|
||||
}
|
||||
if s.n > lpwSizeThreshold {
|
||||
s.println(s.prefix + "dropped " + strconv.Itoa(s.n-n) + " bytes of output")
|
||||
if s.buf != nil && s.buf.Len() != 0 {
|
||||
s.println("*" + s.prefix + s.buf.String())
|
||||
}
|
||||
if s.n >= lpwSizeThreshold {
|
||||
s.println("+" + s.prefix + "write threshold reached, output may be incomplete")
|
||||
}
|
||||
s.mu.RUnlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user