mirror of
https://github.com/coalaura/ffwebp.git
synced 2025-09-08 05:49:54 +00:00
multithreading
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user