diff --git a/client/client_test.go b/client/client_test.go index 9de37776b..e4b1d461e 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -477,7 +477,7 @@ func TestClient_SaveRestoreState(t *testing.T) { // Create a new client shutdownCh := make(chan struct{}) - logger := log.New(config.LogOutput, "", log.LstdFlags) + logger := log.New(c1.config.LogOutput, "", log.LstdFlags) consulSyncer, err := consul.NewSyncer(c1.config.ConsulConfig, shutdownCh, logger) if err != nil { t.Fatalf("err: %v", err) diff --git a/command/agent/agent.go b/command/agent/agent.go index 98cce108e..cd1698512 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -5,7 +5,6 @@ import ( "io" "log" "net" - "os" "path/filepath" "runtime" "strconv" @@ -61,11 +60,6 @@ type Agent struct { // NewAgent is used to create a new agent with the given configuration func NewAgent(config *Config, logOutput io.Writer) (*Agent, error) { - // Ensure we have a log sink - if logOutput == nil { - logOutput = os.Stderr - } - a := &Agent{ config: config, logger: log.New(logOutput, "", log.LstdFlags), diff --git a/nomad/config.go b/nomad/config.go index 0c515b780..3555a9eda 100644 --- a/nomad/config.go +++ b/nomad/config.go @@ -209,6 +209,7 @@ func DefaultConfig() *Config { ProtocolVersion: ProtocolVersionMax, RaftConfig: raft.DefaultConfig(), RaftTimeout: 10 * time.Second, + LogOutput: os.Stderr, RPCAddr: DefaultRPCAddr, SerfConfig: serf.DefaultConfig(), NumSchedulers: 1, diff --git a/nomad/server.go b/nomad/server.go index 7d12c8752..6cdb7d3bf 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -7,7 +7,6 @@ import ( "log" "net" "net/rpc" - "os" "path/filepath" "reflect" "sort" @@ -170,11 +169,6 @@ func NewServer(config *Config, consulSyncer *consul.Syncer, logger *log.Logger) return nil, err } - // Ensure we have a log output - if config.LogOutput == nil { - config.LogOutput = os.Stderr - } - // Create an eval broker evalBroker, err := NewEvalBroker(config.EvalNackTimeout, config.EvalDeliveryLimit) if err != nil { @@ -214,14 +208,14 @@ func NewServer(config *Config, consulSyncer *consul.Syncer, logger *log.Logger) // TODO: TLS... if err := s.setupRPC(nil); err != nil { s.Shutdown() - logger.Printf("[ERR] nomad: failed to start RPC layer: %s", err) + s.logger.Printf("[ERR] nomad: failed to start RPC layer: %s", err) return nil, fmt.Errorf("Failed to start RPC layer: %v", err) } // Initialize the Raft server if err := s.setupRaft(); err != nil { s.Shutdown() - logger.Printf("[ERR] nomad: failed to start Raft: %s", err) + s.logger.Printf("[ERR] nomad: failed to start Raft: %s", err) return nil, fmt.Errorf("Failed to start Raft: %v", err) } @@ -229,14 +223,14 @@ func NewServer(config *Config, consulSyncer *consul.Syncer, logger *log.Logger) s.serf, err = s.setupSerf(config.SerfConfig, s.eventCh, serfSnapshot) if err != nil { s.Shutdown() - logger.Printf("[ERR] nomad: failed to start serf WAN: %s", err) + s.logger.Printf("[ERR] nomad: failed to start serf WAN: %s", err) return nil, fmt.Errorf("Failed to start serf: %v", err) } // Initialize the scheduling workers if err := s.setupWorkers(); err != nil { s.Shutdown() - logger.Printf("[ERR] nomad: failed to start workers: %s", err) + s.logger.Printf("[ERR] nomad: failed to start workers: %s", err) return nil, fmt.Errorf("Failed to start workers: %v", err) }