mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 22:18:14 -05:00
### Purpose Re-enables LOGGER_DISCARD. See #10262. ### Documentation No changes needed, as the docs already mention this variable.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
package slogutil
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -21,10 +22,20 @@ var (
|
||||
}
|
||||
slogDef = slog.New(&formattingHandler{
|
||||
recs: []*lineRecorder{GlobalRecorder, ErrorRecorder},
|
||||
out: os.Stdout,
|
||||
out: logWriter(),
|
||||
})
|
||||
)
|
||||
|
||||
func logWriter() io.Writer {
|
||||
if os.Getenv("LOGGER_DISCARD") != "" {
|
||||
// Hack to completely disable logging, for example when running
|
||||
// benchmarks.
|
||||
return io.Discard
|
||||
}
|
||||
|
||||
return os.Stdout
|
||||
}
|
||||
|
||||
func init() {
|
||||
slog.SetDefault(slogDef)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user