Skip to content

Commit

Permalink
Merge pull request #51 from jehiah/default_logger_51
Browse files Browse the repository at this point in the history
default logger
  • Loading branch information
mreiferson committed Jun 16, 2014
2 parents 394ebba + 0e3a897 commit c40f474
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
5 changes: 0 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ type Config struct {
sync.RWMutex
initOnce sync.Once

verbose bool `opt:"verbose"`

readTimeout time.Duration `opt:"read_timeout" min:"100ms" max:"5m"`
writeTimeout time.Duration `opt:"write_timeout" min:"100ms" max:"5m"`

Expand Down Expand Up @@ -62,7 +60,6 @@ type Config struct {

// NewConfig returns a new default configuration.
//
// "verbose": false (bool)
// "read_timeout": 60s (min: 100ms, max: 5m) (time.Duration)
// "write_timeout": 1s (min: 100ms, max: 5m) (time.Duration)
// "lookupd_poll_interval": 60s (min: 5s, max: 5m) (time.Duration)
Expand Down Expand Up @@ -144,8 +141,6 @@ func (c *Config) initialize() {
//
// It returns an error for an invalid option or value.
//
// verbose (bool): enable verbose logging
//
// read_timeout (time.Duration): the deadline set for network reads
// (min: 100ms, max: 5m)
//
Expand Down
8 changes: 4 additions & 4 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ func TestConfigSet(t *testing.T) {
if err := c.Set("not a real config value", struct{}{}); err == nil {
t.Error("No error when setting an invalid value")
}
if err := c.Set("verbose", "lol"); err == nil {
t.Error("No error when setting `verbose` to an invalid value")
if err := c.Set("tls_v1", "lol"); err == nil {
t.Error("No error when setting `tls_v1` to an invalid value")
}
if err := c.Set("verbose", true); err != nil {
t.Errorf("Error setting `verbose` config: %v", err)
if err := c.Set("tls_v1", true); err != nil {
t.Errorf("Error setting `tls_v1` config: %v", err)
}
}
4 changes: 4 additions & 0 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"math/rand"
"net"
"net/url"
"os"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -130,6 +131,9 @@ func NewConsumer(topic string, channel string, config *Config) (*Consumer, error
channel: channel,
config: config,

logger: log.New(os.Stderr, "", log.Flags()),
logLvl: LogLevelInfo,

incomingMessages: make(chan *Message),

rdyRetryTimers: make(map[string]*time.Timer),
Expand Down
1 change: 0 additions & 1 deletion consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func consumerTest(t *testing.T, deflate bool, snappy bool, tlsv1 bool) {
topicName = topicName + strconv.Itoa(int(time.Now().Unix()))

config := NewConfig()
config.Set("verbose", true)
// so that the test can simulate reaching max requeues and a call to LogFailedMessage
config.Set("default_requeue_delay", 0)
// so that the test wont timeout from backing off
Expand Down
1 change: 0 additions & 1 deletion mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func TestConsumerBackoff(t *testing.T) {

topicName := "test_consumer_commands" + strconv.Itoa(int(time.Now().Unix()))
config := NewConfig()
config.Set("verbose", true)
config.Set("max_in_flight", 5)
config.Set("backoff_multiplier", 10*time.Millisecond)
q, _ := NewConsumer(topicName, "ch", config)
Expand Down
4 changes: 4 additions & 0 deletions producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nsq
import (
"fmt"
"log"
"os"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -64,6 +65,9 @@ func NewProducer(addr string, config *Config) *Producer {
addr: addr,
config: config,

logger: log.New(os.Stderr, "", log.Flags()),
logLvl: LogLevelInfo,

transactionChan: make(chan *ProducerTransaction),
exitChan: make(chan int),
responseChan: make(chan []byte),
Expand Down
1 change: 0 additions & 1 deletion producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ func TestProducerHeartbeat(t *testing.T) {

func readMessages(topicName string, t *testing.T, msgCount int) {
config := NewConfig()
config.Set("verbose", true)
config.Set("default_requeue_delay", 0)
config.Set("max_backoff_duration", time.Millisecond*50)
q, _ := NewConsumer(topicName, "ch", config)
Expand Down

0 comments on commit c40f474

Please sign in to comment.