Skip to content

Commit

Permalink
Fix an issue where MinIO was logging every error twice (minio#8953)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nitisht authored Feb 7, 2020
1 parent 07edb7c commit 15e2ea2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
13 changes: 13 additions & 0 deletions cmd/common-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package cmd

import (
"context"
"crypto/x509"
"encoding/gob"
"errors"
"net"
"path/filepath"
Expand All @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions cmd/gateway-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 0 additions & 12 deletions cmd/server-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package cmd

import (
"context"
"encoding/gob"
"errors"
"fmt"
"net/http"
Expand All @@ -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{
Expand Down

0 comments on commit 15e2ea2

Please sign in to comment.