]> Cypherpunks.ru repositories - goredo.git/commitdiff
More simpler statusline cleaning v1.4.1
authorSergey Matveev <stargrave@stargrave.org>
Thu, 29 Apr 2021 12:02:56 +0000 (15:02 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 29 Apr 2021 12:02:56 +0000 (15:02 +0300)
doc/news.texi
log.go
status.go
usage.go

index 0c29352c6349a04a57494d899c71980a580c6ee8..36f6aa948c965390bdd87841e8bbe956e9c409e8 100644 (file)
@@ -1,6 +1,13 @@
 @node News
 @unnumbered News
 
+@anchor{Release 1.4.1}
+@section Release 1.4.1
+@itemize
+@item
+    Even more simpler statusline cleaning function.
+@end itemize
+
 @anchor{Release 1.4.0}
 @section Release 1.4.0
 @itemize
diff --git a/log.go b/log.go
index f4248de80d30a9d73146d688489f0d18efb2b886..4d8a982813a1e58a31c43fafbcad3f4d2d4336dd 100644 (file)
--- 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()
 }
 
index 7b45905cd089ef3fe49357b649d0dd375fad8ecd..0852dbd03c7579420af105f386349b17656c52ce 100644 (file)
--- a/status.go
+++ b/status.go
@@ -96,9 +96,9 @@ func statusInit() {
                                        CJS, done, CReset,
                                )
                        }
+                       out = erasedStatus(out, "\r")
                        LogMutex.Lock()
-                       os.Stderr.WriteString(erasedStatus(out, "\r"))
-                       LogWasStatus = true
+                       os.Stderr.WriteString(out)
                        LogMutex.Unlock()
                }
        }()
index 179eb15f49a805382d45853068889938e7bc551c..81e954dad5599880ec4b10ff0c6e853ffdeb23a8 100644 (file)
--- a/usage.go
+++ b/usage.go
@@ -24,7 +24,7 @@ import (
 )
 
 const (
-       Version  = "1.4.0"
+       Version  = "1.4.1"
        Warranty = `Copyright (C) 2020-2021 Sergey Matveev
 
 This program is free software: you can redistribute it and/or modify