quiet output

This commit is contained in:
Jeff Carr 2025-01-08 04:08:34 -06:00
parent b0fca659c5
commit 0ca1240c75
3 changed files with 13 additions and 8 deletions

2
log.go
View File

@ -4,6 +4,7 @@ import (
"go.wit.com/log"
)
var NOW *log.LogFlag
var INFO *log.LogFlag
var WARN *log.LogFlag
@ -11,6 +12,7 @@ func init() {
full := "go.wit.com/lib/protobuf/gitpb"
short := "gitpb"
NOW = log.NewFlag("NOW", true, full, short, "stuff that's supposed to print")
INFO = log.NewFlag("INFO", false, full, short, "general gitpb things")
WARN = log.NewFlag("WARN", true, full, short, "gitpb warnings")
}

View File

@ -58,6 +58,9 @@ func (repo *Repo) CheckDirty() bool {
pbnow := timestamppb.New(time.Now())
repo.Times.LastDirty = pbnow
repo.Dirty = bad
if bad {
repo.State = "dirty"
}
return bad
}

View File

@ -18,9 +18,9 @@ func (repo *Repo) Run(cmd []string) cmd.Status {
result := shell.PathRun(repo.FullPath, cmd)
output := strings.Join(result.Stdout, "\n")
if result.Error != nil {
log.Warn("cmd:", cmd)
log.Warn("ouptput:", output)
log.Warn("failed with error:", result.Error)
log.Log(WARN, "cmd:", cmd)
log.Log(WARN, "ouptput:", output)
log.Log(WARN, "failed with error:", result.Error)
}
return result
}
@ -32,13 +32,13 @@ func (repo *Repo) RunQuiet(cmd []string) cmd.Status {
func (repo *Repo) RunEcho(cmd []string) cmd.Status {
result := shell.PathRunQuiet(repo.FullPath, cmd)
log.Info("cmd:", repo.FullPath, cmd)
log.Warn("cmd.Exit:", result.Exit, "cmd.Error:", result.Error)
log.Log(NOW, "cmd:", repo.FullPath, cmd)
log.Warn(WARN, "cmd.Exit:", result.Exit, "cmd.Error:", result.Error)
for _, line := range result.Stdout {
log.Info("STDOUT:", line)
log.Log(NOW, "STDOUT:", line)
}
for _, line := range result.Stderr {
log.Info("STDERR:", line)
log.Log(NOW, "STDERR:", line)
}
return result
}
@ -48,7 +48,7 @@ func (repo *Repo) RunRealtime(cmd []string) cmd.Status {
}
func (repo *Repo) RunRealtimeVerbose(cmd []string) cmd.Status {
log.Info("Run:", repo.GetFullPath(), cmd)
log.Log(NOW, "Run:", repo.GetFullPath(), cmd)
return shell.PathRunRealtime(repo.GetFullPath(), cmd)
}