Skip to content

Commit

Permalink
fix(progressbar): Progressbar and Logger did not work together co…
Browse files Browse the repository at this point in the history
…rrectly
  • Loading branch information
MarvinJWendt committed Jan 29, 2024
1 parent e8f4568 commit 9f11831
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (l Logger) print(level LogLevel, msg string, args []LoggerArgument) {
loggerMutex.Lock()
defer loggerMutex.Unlock()

_, _ = l.Writer.Write([]byte(line + "\n"))
Fprintln(l.Writer, line)
}

func (l Logger) renderColorful(level LogLevel, msg string, args []LoggerArgument) (result string) {
Expand Down
3 changes: 2 additions & 1 deletion print.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pterm
import (
"fmt"
"io"
"os"
"strings"

"github.com/gookit/color"
Expand Down Expand Up @@ -45,7 +46,7 @@ func Sprinto(a ...interface{}) string {
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
func Print(a ...interface{}) {
Fprint(nil, a...)
Fprint(os.Stdout, a...)
}

// Println formats using the default formats for its operands and writes to standard output.
Expand Down
2 changes: 2 additions & 0 deletions progressbar_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"math"
"os"
"strings"
"time"

Expand All @@ -32,6 +33,7 @@ var DefaultProgressbar = ProgressbarPrinter{
ShowElapsedTime: true,
BarFiller: Gray("█"),
MaxWidth: 80,
Writer: os.Stdout,
}

// ProgressbarPrinter shows a progress animation in the terminal.
Expand Down

0 comments on commit 9f11831

Please sign in to comment.