Skip to content

Commit

Permalink
Merge pull request #522 from terinjokes/terin/log-sync-writer
Browse files Browse the repository at this point in the history
fix(shipping): use `log.NewSyncWriter` in example
  • Loading branch information
ChrisHines authored May 6, 2017
2 parents 1dcd5d6 + 5098c66 commit 3df66f4
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions examples/shipping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"os"
"os/signal"
"sync"
"syscall"
"time"

Expand Down Expand Up @@ -46,8 +45,7 @@ func main() {
flag.Parse()

var logger log.Logger
logger = log.NewLogfmtLogger(os.Stderr)
logger = &serializedLogger{Logger: logger}
logger = log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
logger = log.With(logger, "ts", log.DefaultTimestampUTC)

var (
Expand Down Expand Up @@ -200,14 +198,3 @@ func storeTestData(r cargo.Repository) {
panic(err)
}
}

type serializedLogger struct {
mtx sync.Mutex
log.Logger
}

func (l *serializedLogger) Log(keyvals ...interface{}) error {
l.mtx.Lock()
defer l.mtx.Unlock()
return l.Logger.Log(keyvals...)
}

0 comments on commit 3df66f4

Please sign in to comment.