more compat for 'fmt' package

This commit is contained in:
Jeff Carr 2025-08-16 16:24:47 -05:00
parent 466a3c6076
commit 8c7078908b
4 changed files with 22 additions and 7 deletions

View File

@ -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...)
}

View File

@ -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()

View File

@ -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...)

10
sscan.go Normal file
View File

@ -0,0 +1,10 @@
package log
import "fmt"
// func Sprint(a ...any) string {
// return realSprint(a...)
func Sscanf(f string, thing string, a ...any) (int, error) {
return fmt.Sscanf(f, thing, a...)
}