Fix an issue where MinIO was logging every error twice (#8953)

The logging subsystem was initialized under init() method in
both gateway-main.go and server-main.go which are part of
same package. This created two logging targets and hence
errors were logged twice. This PR moves the init() method
to common-main.go
master
Nitish Tiwari 5 years ago committed by GitHub
parent 07edb7c7f8
commit 15e2ea2c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      cmd/common-main.go
  2. 9
      cmd/gateway-main.go
  3. 12
      cmd/server-main.go

@ -17,7 +17,9 @@
package cmd
import (
"context"
"crypto/x509"
"encoding/gob"
"errors"
"net"
"path/filepath"
@ -34,6 +36,17 @@ import (
"github.com/minio/minio/pkg/env"
)
func init() {
logger.Init(GOPATH, GOROOT)
logger.RegisterError(config.FmtError)
// Initialize globalConsoleSys system
globalConsoleSys = NewConsoleLogger(context.Background())
logger.AddTarget(globalConsoleSys)
gob.Register(StorageErr(""))
}
func verifyObjectLayerFeatures(name string, objAPI ObjectLayer) {
if (globalAutoEncryption || GlobalKMS != nil) && !objAPI.IsEncryptionSupported() {
logger.Fatal(errInvalidArgument,

@ -35,15 +35,6 @@ import (
"github.com/minio/minio/pkg/env"
)
func init() {
logger.Init(GOPATH, GOROOT)
logger.RegisterError(config.FmtError)
// Initialize globalConsoleSys system
globalConsoleSys = NewConsoleLogger(context.Background())
logger.AddTarget(globalConsoleSys)
}
var (
gatewayCmd = cli.Command{
Name: "gateway",

@ -18,7 +18,6 @@ package cmd
import (
"context"
"encoding/gob"
"errors"
"fmt"
"net/http"
@ -37,17 +36,6 @@ import (
"github.com/minio/minio/pkg/env"
)
func init() {
logger.Init(GOPATH, GOROOT)
logger.RegisterError(config.FmtError)
// Initialize globalConsoleSys system
globalConsoleSys = NewConsoleLogger(context.Background())
logger.AddTarget(globalConsoleSys)
gob.Register(StorageErr(""))
}
// ServerFlags - server command specific flags
var ServerFlags = []cli.Flag{
cli.StringFlag{

Loading…
Cancel
Save