mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
Print golang http errors in MinIO log format (#16465)
This commit is contained in:
parent
027ff0f3a8
commit
1fd7946dce
@ -589,7 +589,7 @@ func serverMain(ctx *cli.Context) {
|
|||||||
UseIdleTimeout(ctx.Duration("idle-timeout")).
|
UseIdleTimeout(ctx.Duration("idle-timeout")).
|
||||||
UseReadHeaderTimeout(ctx.Duration("read-header-timeout")).
|
UseReadHeaderTimeout(ctx.Duration("read-header-timeout")).
|
||||||
UseBaseContext(GlobalContext).
|
UseBaseContext(GlobalContext).
|
||||||
UseCustomLogger(log.New(io.Discard, "", 0)) // Turn-off random logging by Go stdlib
|
UseCustomLogger(log.New(&goHTTPLogger{}, "", 0))
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
globalHTTPServerErrorCh <- httpServer.Start(GlobalContext)
|
globalHTTPServerErrorCh <- httpServer.Start(GlobalContext)
|
||||||
|
10
cmd/utils.go
10
cmd/utils.go
@ -1245,3 +1245,13 @@ func MockOpenIDTestUserInteraction(ctx context.Context, pro OpenIDClientAppParam
|
|||||||
// fmt.Printf("TOKEN: %s\n", rawIDToken)
|
// fmt.Printf("TOKEN: %s\n", rawIDToken)
|
||||||
return rawIDToken, nil
|
return rawIDToken, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom logger for golang http logs
|
||||||
|
type goHTTPLogger struct{}
|
||||||
|
|
||||||
|
func (goHTTPLogger) Write(p []byte) (int, error) {
|
||||||
|
// Golang std logger ensures that the error message will be sent
|
||||||
|
// in one Write call so it is okay to print it directly.
|
||||||
|
logger.LogOnceIf(context.Background(), fmt.Errorf("%s", string(p)), "go-http-logging")
|
||||||
|
return len(p), nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user