internal/pkg: highlight cache verbose output
Test / Create distribution (push) Successful in 53s
Test / Sandbox (push) Successful in 2m49s
Test / Hakurei (push) Successful in 4m33s
Test / Sandbox (race detector) (push) Successful in 5m50s
Test / Hakurei (race detector) (push) Successful in 7m11s
Test / ShareFS (push) Successful in 7m34s
Test / Flake checks (push) Successful in 1m21s
Test / Create distribution (push) Successful in 53s
Test / Sandbox (push) Successful in 2m49s
Test / Hakurei (push) Successful in 4m33s
Test / Sandbox (race detector) (push) Successful in 5m50s
Test / Hakurei (race detector) (push) Successful in 7m11s
Test / ShareFS (push) Successful in 7m34s
Test / Flake checks (push) Successful in 1m21s
This highlights sections of messages, increasing readability in some cases. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
+56
-16
@@ -779,6 +779,8 @@ type Cache struct {
|
||||
wg sync.WaitGroup
|
||||
// Reports new cures and passed to [Artifact].
|
||||
msg message.Msg
|
||||
// Select graphics rendition sequences, populated by Open.
|
||||
sgrRes, sgrIdent, sgrWarn, sgrErr string
|
||||
|
||||
// Directory where all [Cache] related files are placed.
|
||||
base *check.Absolute
|
||||
@@ -1511,10 +1513,10 @@ func (c *Cache) openFile(
|
||||
id := c.Ident(f)
|
||||
if c.msg.IsVerbose() {
|
||||
rn := reportName(f, id)
|
||||
c.msg.Verbosef("curing %s in memory...", rn)
|
||||
c.msg.Verbosef("curing %s%s%s in memory...", c.sgrIdent, rn, c.sgrRes)
|
||||
defer func() {
|
||||
if err == nil {
|
||||
c.msg.Verbosef("opened %s for reading", rn)
|
||||
c.msg.Verbosef("opened %s%s%s for reading", c.sgrIdent, rn, c.sgrRes)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -1893,7 +1895,10 @@ func (mr *measuredReader) Close() (err error) {
|
||||
}
|
||||
|
||||
if n > 0 {
|
||||
mr.c.msg.Verbosef("missed %d bytes on measured reader", n)
|
||||
mr.c.msg.Verbosef(
|
||||
"%smissed %d bytes on measured reader%s",
|
||||
mr.c.sgrWarn, n, mr.c.sgrRes,
|
||||
)
|
||||
}
|
||||
|
||||
if err = mr.r.Close(); err != nil {
|
||||
@@ -2154,8 +2159,9 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
)
|
||||
if errors.Is(err, os.ErrExist) {
|
||||
c.msg.Verbosef(
|
||||
"creating alternative over %s for artifact %s",
|
||||
Encode(substitute.Value()), ids,
|
||||
"creating alternative over %s%s%s for artifact %s%s%s",
|
||||
c.sgrIdent, Encode(substitute.Value()), c.sgrRes,
|
||||
c.sgrIdent, ids, c.sgrRes,
|
||||
)
|
||||
err = nil
|
||||
}
|
||||
@@ -2198,15 +2204,18 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
whence = WNew
|
||||
if c.msg.IsVerbose() {
|
||||
rn := reportName(a, id)
|
||||
c.msg.Verbosef("curing %s...", rn)
|
||||
c.msg.Verbosef("curing %s%s%s...", c.sgrIdent, rn, c.sgrRes)
|
||||
defer func() {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if checksums != "" {
|
||||
c.msg.Verbosef("cured %s checksum %s", rn, checksums)
|
||||
c.msg.Verbosef(
|
||||
"cured %s%s%s checksum %s%s%s",
|
||||
c.sgrIdent, rn, c.sgrRes,
|
||||
c.sgrIdent, checksums, c.sgrRes)
|
||||
} else {
|
||||
c.msg.Verbosef("cured %s", rn)
|
||||
c.msg.Verbosef("cured %s%s%s", c.sgrIdent, rn, c.sgrRes)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -2301,7 +2310,11 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
c.exitCure(a, curesExempt)
|
||||
if err != nil {
|
||||
if c.msg.IsVerbose() {
|
||||
c.msg.Verbosef("cure file %s: %v", reportName(f, id), err)
|
||||
c.msg.Verbosef(
|
||||
"cure file %s%s%s: %s%v%s",
|
||||
c.sgrIdent, reportName(f, id), c.sgrRes,
|
||||
c.sgrErr, err, c.sgrRes,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -2348,7 +2361,11 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
c.exitCure(a, curesExempt)
|
||||
if err != nil {
|
||||
if c.msg.IsVerbose() {
|
||||
c.msg.Verbosef("cure trivial %s: %v", reportName(ca, id), err)
|
||||
c.msg.Verbosef(
|
||||
"cure trivial %s%s%s: %s%v%s",
|
||||
c.sgrIdent, reportName(ca, id), c.sgrRes,
|
||||
c.sgrErr, err, c.sgrRes,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -2358,7 +2375,11 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
var externChecksum unique.Handle[Checksum]
|
||||
if externChecksum, err = c.tryExtern(ctx, id); err != nil {
|
||||
if c.msg.IsVerbose() {
|
||||
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
|
||||
c.msg.Verbosef(
|
||||
"extern %s%s%s: %s%v%s",
|
||||
c.sgrIdent, reportName(ca, id), c.sgrRes,
|
||||
c.sgrErr, err, c.sgrRes,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -2398,8 +2419,8 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
if sum == zeroChecksum {
|
||||
if c.msg.IsVerbose() {
|
||||
c.msg.Verbosef(
|
||||
"input %s not available",
|
||||
reportName(d, did),
|
||||
"input %s%s%s not available",
|
||||
c.sgrIdent, reportName(d, did), c.sgrRes,
|
||||
)
|
||||
}
|
||||
err = HangingInputError(did)
|
||||
@@ -2463,7 +2484,11 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
if checksum != zeroChecksum && externChecksum != checksum {
|
||||
err = &ChecksumMismatchError{externChecksum.Value(), checksum.Value()}
|
||||
if c.msg.IsVerbose() {
|
||||
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
|
||||
c.msg.Verbosef(
|
||||
"extern %s%s%s: %s%v%s",
|
||||
c.sgrIdent, reportName(ca, id), c.sgrRes,
|
||||
c.sgrErr, err, c.sgrRes,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -2512,7 +2537,11 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
}
|
||||
if err != nil {
|
||||
if c.msg.IsVerbose() {
|
||||
c.msg.Verbosef("cure %s: %v", reportName(ca, id), err)
|
||||
c.msg.Verbosef(
|
||||
"cure %s%s%s: %s%v%s",
|
||||
c.sgrIdent, reportName(ca, id), c.sgrRes,
|
||||
c.sgrErr, err, c.sgrRes,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -2563,7 +2592,11 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
|
||||
Want: checksum.Value(),
|
||||
}
|
||||
if c.msg.IsVerbose() {
|
||||
c.msg.Verbosef("validate %s: %v", reportName(a, id), err)
|
||||
c.msg.Verbosef(
|
||||
"validate %s%s%s: %s%v%s",
|
||||
c.sgrIdent, reportName(a, id), c.sgrRes,
|
||||
c.sgrErr, err, c.sgrRes,
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -2898,6 +2931,13 @@ func Open(
|
||||
return nil, UnsupportedVariantError(s)
|
||||
}
|
||||
|
||||
if a.Flags&CColourOutput != 0 {
|
||||
c.sgrRes = "\x1b[0m"
|
||||
c.sgrIdent = "\x1b[1m"
|
||||
c.sgrWarn = "\x1b[35m"
|
||||
c.sgrErr = "\x1b[1;31m"
|
||||
}
|
||||
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user