Provide `nomad.Config` with a default `LogOutput` of `os.StdErr`

This commit is contained in:
Sean Chittenden 2016-06-17 06:44:10 -07:00
parent 9a60999100
commit 46e2d54acf
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
4 changed files with 6 additions and 17 deletions

View File

@ -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)

View File

@ -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),

View File

@ -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,

View File

@ -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)
}