more compat for 'fmt' package
This commit is contained in:
parent
466a3c6076
commit
8c7078908b
6
error.go
6
error.go
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
func Error(err error, a ...any) {
|
func Error(err error, a ...any) {
|
||||||
if ERROR.Disabled() {
|
if ERROR.Disabled() {
|
||||||
return
|
return
|
||||||
|
@ -11,3 +13,7 @@ func Error(err error, a ...any) {
|
||||||
realPrintln("Error:", err)
|
realPrintln("Error:", err)
|
||||||
realPrintln(a...)
|
realPrintln(a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Errorf(f string, a ...any) error {
|
||||||
|
return fmt.Errorf(f, a...)
|
||||||
|
}
|
||||||
|
|
2
flags.go
2
flags.go
|
@ -148,7 +148,7 @@ func (f *LogFlag) Disabled() bool {
|
||||||
if !f.Ok() {
|
if !f.Ok() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return ! f.b
|
return !f.b
|
||||||
}
|
}
|
||||||
|
|
||||||
// just the opposite of Disabled()
|
// just the opposite of Disabled()
|
||||||
|
|
11
reallog.go
11
reallog.go
|
@ -19,7 +19,6 @@ func Timestamps(b bool) {
|
||||||
timestamps = b
|
timestamps = b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var captureMode io.Writer
|
var captureMode io.Writer
|
||||||
|
|
||||||
func CaptureMode(w io.Writer) {
|
func CaptureMode(w io.Writer) {
|
||||||
|
@ -64,11 +63,11 @@ func realPrintln(a ...any) {
|
||||||
} else {
|
} else {
|
||||||
// put timestamps on each line
|
// put timestamps on each line
|
||||||
if captureMode == nil {
|
if captureMode == nil {
|
||||||
if timestamps {
|
if timestamps {
|
||||||
reallog.Println(a...)
|
reallog.Println(a...)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(a...)
|
fmt.Println(a...)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: add datestamp
|
// TODO: add datestamp
|
||||||
fmt.Fprintln(captureMode, a...)
|
fmt.Fprintln(captureMode, a...)
|
||||||
|
|
Loading…
Reference in New Issue