resolve logging

This commit is contained in:
a 2024-06-24 11:51:45 -05:00
parent 38fba5916c
commit e8d2c50cd9
No known key found for this signature in database
GPG key ID: 374BC539FE795AF0

View file

@ -16,7 +16,6 @@ package caddy
import ( import (
"encoding/json" "encoding/json"
"flag"
"fmt" "fmt"
"io" "io"
"log" "log"
@ -700,12 +699,7 @@ type defaultCustomLog struct {
// and enables INFO-level logs and higher. // and enables INFO-level logs and higher.
func newDefaultProductionLog() (*defaultCustomLog, error) { func newDefaultProductionLog() (*defaultCustomLog, error) {
cl := new(CustomLog) cl := new(CustomLog)
f := flag.Lookup("test.v") cl.writerOpener = StderrWriter{}
if (f != nil && f.Value.String() != "true") || strings.Contains(os.Args[0], ".test") {
cl.writerOpener = &DiscardWriter{}
} else {
cl.writerOpener = StderrWriter{}
}
var err error var err error
cl.writer, err = cl.writerOpener.OpenWriter() cl.writer, err = cl.writerOpener.OpenWriter()