Merge pull request #43511 from thaJeztah/no_logrus_fatal

This commit is contained in:
Samuel Karp 2022-04-21 11:33:43 -07:00 committed by GitHub
commit ccb691a427
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 24 additions and 37 deletions

View file

@ -120,10 +120,10 @@ type byTimestamp []wrappedEvent
// init registers the awslogs driver
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(name, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -48,7 +48,7 @@ var mu sync.Mutex
func init() {
providerHandle = windows.InvalidHandle
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -62,10 +62,10 @@ const (
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(name, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -43,13 +43,12 @@ var (
)
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(name, ValidateLogOpts); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -14,7 +14,6 @@ import (
"github.com/Graylog2/go-gelf/gelf"
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/daemon/logger/loggerutils"
"github.com/sirupsen/logrus"
)
const name = "gelf"
@ -28,10 +27,10 @@ type gelfLogger struct {
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(name, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -14,7 +14,6 @@ import (
"github.com/coreos/go-systemd/v22/journal"
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/daemon/logger/loggerutils"
"github.com/sirupsen/logrus"
)
const name = "journald"
@ -27,10 +26,10 @@ type journald struct {
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(name, validateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -15,7 +15,6 @@ import (
"github.com/docker/docker/daemon/logger/loggerutils"
units "github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// Name is the name of the file that the jsonlogger logs to.
@ -32,10 +31,10 @@ type JSONFileLogger struct {
func init() {
if err := logger.RegisterLogDriver(Name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(Name, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -14,7 +14,6 @@ import (
"github.com/docker/docker/errdefs"
units "github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
const (
@ -49,10 +48,10 @@ func ValidateLogOpt(cfg map[string]string) error {
func init() {
if err := logger.RegisterLogDriver(Name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(Name, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -29,10 +29,10 @@ const (
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(name, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -142,10 +142,10 @@ const (
func init() {
if err := logger.RegisterLogDriver(driverName, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(driverName, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -16,7 +16,6 @@ import (
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/daemon/logger/loggerutils"
"github.com/docker/go-connections/tlsconfig"
"github.com/sirupsen/logrus"
)
const (
@ -54,10 +53,10 @@ type syslogger struct {
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
logrus.Fatal(err)
panic(err)
}
if err := logger.RegisterLogOptValidator(name, ValidateLogOpt); err != nil {
logrus.Fatal(err)
panic(err)
}
}

View file

@ -54,8 +54,7 @@ func init() {
testEnv, err = environment.New()
if err != nil {
fmt.Println(err)
os.Exit(1)
panic(err)
}
}

View file

@ -34,13 +34,11 @@ type NetworkToSplit struct {
func init() {
var err error
if PredefinedGlobalScopeDefaultNetworks, err = splitNetworks(globalScopeDefaultNetworks); err != nil {
//we are going to panic in case of error as we should never get into this state
panic("InitAddressPools failed to initialize the global scope default address pool")
panic("failed to initialize the global scope default address pool: " + err.Error())
}
if PredefinedLocalScopeDefaultNetworks, err = splitNetworks(localScopeDefaultNetworks); err != nil {
//we are going to panic in case of error as we should never get into this state
panic("InitAddressPools failed to initialize the local scope default address pool")
panic("failed to initialize the local scope default address pool: " + err.Error())
}
}

View file

@ -1,4 +0,0 @@
package chrootarchive // import "github.com/docker/docker/pkg/chrootarchive"
func init() {
}