X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=log.go;h=4d8a982813a1e58a31c43fafbcad3f4d2d4336dd;hb=ce60c3b66ff2d3f14392cac1eb3ec6dfc33fc893;hp=f4248de80d30a9d73146d688489f0d18efb2b886;hpb=ff2443f496cbf7f648b84a78e468dc3f130c37f2;p=goredo.git diff --git a/log.go b/log.go index f4248de..4d8a982 100644 --- a/log.go +++ b/log.go @@ -70,7 +70,6 @@ var ( LogMutex sync.Mutex KeyEraseLine string - LogWasStatus bool ) func init() { @@ -88,10 +87,10 @@ func init() { } func erasedStatus(s, end string) string { - if LogWasStatus { - s += KeyEraseLine + if NoProgress { + return s + end } - return s + end + return s + KeyEraseLine + end } func trace(level, format string, args ...interface{}) { @@ -101,10 +100,9 @@ func trace(level, format string, args ...interface{}) { } switch level { case CNone: - p = StderrPrefix + p + fmt.Sprintf(format, args...) + p = erasedStatus(StderrPrefix+p+fmt.Sprintf(format, args...), "\n") LogMutex.Lock() - os.Stderr.WriteString(erasedStatus(p, "\n")) - LogWasStatus = false + os.Stderr.WriteString(p) LogMutex.Unlock() return case CDebug: @@ -139,9 +137,9 @@ func trace(level, format string, args ...interface{}) { } msg := fmt.Sprintf(format, args...) msg = StderrPrefix + colourize(level, p+strings.Repeat(". ", Level)+msg) + msg = erasedStatus(msg, "\n") LogMutex.Lock() - os.Stderr.WriteString(erasedStatus(msg, "\n")) - LogWasStatus = false + os.Stderr.WriteString(msg) LogMutex.Unlock() }