[server] Wrap fasthttp and Go http logging into custom logger.

This commit is contained in:
Ciprian Dorin Craciun 2021-12-16 17:40:25 +02:00
parent e2f11ea2a8
commit 52c94ffa7b

View file

@ -10,6 +10,7 @@ import "crypto/tls"
import "flag" import "flag"
import "fmt" import "fmt"
import "io" import "io"
import "io/ioutil"
import "log" import "log"
import "net" import "net"
import "net/http" import "net/http"
@ -500,6 +501,15 @@ func (_server *server) ServeHTTP (_response http.ResponseWriter, _request *http.
func (_server *server) Printf (_format string, _arguments ... interface{}) () {
if !_server.quiet {
log.Printf ("[ee] [47765179] [fasthttp] " + _format, _arguments ...)
}
}
func Main () () { func Main () () {
log.SetPrefix (fmt.Sprintf ("[%8d] ", os.Getpid ())) log.SetPrefix (fmt.Sprintf ("[%8d] ", os.Getpid ()))
@ -834,12 +844,12 @@ func main_0 () (error) {
if _limitMemory != 0 { if _limitMemory != 0 {
_processArguments = append (_processArguments, "--limit-memory", fmt.Sprintf ("%d", _limitMemory)) _processArguments = append (_processArguments, "--limit-memory", fmt.Sprintf ("%d", _limitMemory))
} }
if _debug {
_processArguments = append (_processArguments, "--debug")
}
if _quiet { if _quiet {
_processArguments = append (_processArguments, "--quiet") _processArguments = append (_processArguments, "--quiet")
} }
if _debug {
_processArguments = append (_processArguments, "--debug")
}
if _dummy { if _dummy {
_processArguments = append (_processArguments, "--dummy") _processArguments = append (_processArguments, "--dummy")
} }
@ -1230,8 +1240,8 @@ func main_0 () (error) {
securityHeadersEnabled : _securityHeadersEnabled, securityHeadersEnabled : _securityHeadersEnabled,
http1Disabled : _http1Disabled, http1Disabled : _http1Disabled,
http2Disabled : _http2Disabled, http2Disabled : _http2Disabled,
debug : _debug,
quiet : _quiet, quiet : _quiet,
debug : _debug,
dummy : _dummy, dummy : _dummy,
delay : _delay, delay : _delay,
} }
@ -1322,6 +1332,8 @@ func main_0 () (error) {
CloseOnShutdown : true, CloseOnShutdown : true,
DisableKeepalive : false, DisableKeepalive : false,
Logger : _server,
} }
@ -1356,6 +1368,11 @@ func main_0 () (error) {
panic ("[1b618ffe]") panic ("[1b618ffe]")
} }
if !_quiet {
_https2Server.ErrorLog = log.New (os.Stderr, log.Prefix () + "[ee] [f734edc4] [gohttp] ", 0)
} else {
_https2Server.ErrorLog = log.New (ioutil.Discard, "", 0)
}