1
0
mirror of https://github.com/coalaura/ffwebp.git synced 2025-09-08 05:49:54 +00:00

multithreading

This commit is contained in:
Laura
2025-08-13 03:57:52 +02:00
parent 96df5c36fa
commit 210ac5a42b
2 changed files with 93 additions and 23 deletions

View File

@@ -3,6 +3,7 @@ package logx
import (
"fmt"
"image"
"io"
"os"
"sync/atomic"
"time"
@@ -18,11 +19,15 @@ func SetSilent() {
enabled.Store(false)
}
func Printf(format string, a ...any) {
func Fprintf(writer io.Writer, format string, a ...any) {
if !enabled.Load() {
return
}
if writer == nil {
writer = os.Stderr
}
for i, v := range a {
switch r := v.(type) {
case time.Time:
@@ -36,15 +41,19 @@ func Printf(format string, a ...any) {
}
}
fmt.Fprintf(os.Stderr, format, a...)
fmt.Fprintf(writer, format, a...)
}
func PrintKV(codec, key string, val any) {
func Printf(format string, a ...any) {
Fprintf(os.Stderr, format, a...)
}
func Print(message string) {
if !enabled.Load() {
return
}
Printf("%s: %s=%v\n", codec, key, val)
fmt.Fprint(os.Stderr, message)
}
func Errorf(f string, a ...any) {