Skip to content

Commit

Permalink
feat: Warns should go to stderr (#149)
Browse files Browse the repository at this point in the history
Signed-off-by: AlexNg <contact@ngjx.org>
  • Loading branch information
caffeine-addictt authored Oct 2, 2024
1 parent 6cac25f commit 9923800
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions internal/log/warning.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package log

import "fmt"
import (
"fmt"
"os"
)

func Warnf(format string, a ...any) {
if logLevel <= WARNING {
fmt.Printf(warnPrefix+format, a...)
fmt.Fprintf(os.Stderr, warnPrefix+format, a...)
}
}

func Warnln(a ...any) {
if logLevel <= WARNING {
fmt.Print(warnPrefix)
fmt.Println(a...)
fmt.Fprint(os.Stderr, warnPrefix)
fmt.Fprintln(os.Stderr, a...)
}
}

func Warn(v ...any) {
if logLevel <= WARNING {
fmt.Print(warnPrefix)
fmt.Print(v...)
fmt.Fprint(os.Stderr, warnPrefix)
fmt.Fprint(os.Stderr, v...)
}
}

0 comments on commit 9923800

Please sign in to comment.