Unverified Commit c3871677 authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

Fixed race condition in builder (#704)

parent b55722f7
...@@ -40,9 +40,12 @@ type Logger interface { ...@@ -40,9 +40,12 @@ type Logger interface {
type LoggerToCustomStreams struct { type LoggerToCustomStreams struct {
Stdout io.Writer Stdout io.Writer
Stderr io.Writer Stderr io.Writer
mux sync.Mutex
} }
func (s LoggerToCustomStreams) Fprintln(w io.Writer, level string, format string, a ...interface{}) { func (s LoggerToCustomStreams) Fprintln(w io.Writer, level string, format string, a ...interface{}) {
s.mux.Lock()
defer s.mux.Unlock()
target := s.Stdout target := s.Stdout
if w == os.Stderr { if w == os.Stderr {
target = s.Stderr target = s.Stderr
...@@ -51,6 +54,8 @@ func (s LoggerToCustomStreams) Fprintln(w io.Writer, level string, format string ...@@ -51,6 +54,8 @@ func (s LoggerToCustomStreams) Fprintln(w io.Writer, level string, format string
} }
func (s LoggerToCustomStreams) UnformattedFprintln(w io.Writer, str string) { func (s LoggerToCustomStreams) UnformattedFprintln(w io.Writer, str string) {
s.mux.Lock()
defer s.mux.Unlock()
target := s.Stdout target := s.Stdout
if w == os.Stderr { if w == os.Stderr {
target = s.Stderr target = s.Stderr
...@@ -59,6 +64,8 @@ func (s LoggerToCustomStreams) UnformattedFprintln(w io.Writer, str string) { ...@@ -59,6 +64,8 @@ func (s LoggerToCustomStreams) UnformattedFprintln(w io.Writer, str string) {
} }
func (s LoggerToCustomStreams) UnformattedWrite(w io.Writer, data []byte) { func (s LoggerToCustomStreams) UnformattedWrite(w io.Writer, data []byte) {
s.mux.Lock()
defer s.mux.Unlock()
target := s.Stdout target := s.Stdout
if w == os.Stderr { if w == os.Stderr {
target = s.Stderr target = s.Stderr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment