Skip to content

Commit

Permalink
Fix logger breaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel2392 committed May 5, 2024
1 parent 9212675 commit 10c6d96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func main() {
logger.Setup(&logger.Logger{
Level: logger.InfoLevel,
Prefix: "quickgo",
OutputTime: true,
WrapPrefix: quickgo.ColoredLogWrapper,
})

Expand Down
12 changes: 9 additions & 3 deletions quickgo/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type Logger struct {
// Suffix is the suffix for each log message.
Suffix string

// Display a timestamp alongside the log message.
OutputTime bool

// Outputs for the log messages.
OutputDebug io.Writer
OutputInfo io.Writer
Expand Down Expand Up @@ -233,10 +236,13 @@ func (l *Logger) writePrefix(level LogLevel, w io.Writer) {
}

_, _ = b.Write([]byte(level.String()))
_, _ = b.Write([]byte(" / "))

var t = time.Now().Format("2006-01-02 15:04:05")
_, _ = b.Write([]byte(t))
if l.OutputTime {
_, _ = b.Write([]byte(" / "))
var t = time.Now().Format("2006-01-02 15:04:05")
_, _ = b.Write([]byte(t))
}

_, _ = b.Write([]byte("]: "))

var prefix = b.String()
Expand Down

0 comments on commit 10c6d96

Please sign in to comment.