-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #892 from tonistiigi/warnings-summary
Show summary of build warnings.
- v0.21.0
- v0.21.0-rc3
- v0.21.0-rc2
- v0.21.0-rc1
- v0.20.1
- v0.20.0
- v0.20.0-rc3
- v0.20.0-rc2
- v0.20.0-rc1
- v0.19.3
- v0.19.2
- v0.19.1
- v0.19.0
- v0.19.0-rc2
- v0.19.0-rc1
- v0.18.0
- v0.18.0-rc3
- v0.18.0-rc2
- v0.18.0-rc1
- v0.17.1
- v0.17.0
- v0.17.0-rc2
- v0.17.0-rc1
- v0.16.2
- v0.16.1
- v0.16.0
- v0.16.0-rc2
- v0.16.0-rc1
- v0.15.1
- v0.15.0
- v0.15.0-rc2
- v0.15.0-rc1
- v0.14.1
- v0.14.0
- v0.14.0-rc2
- v0.14.0-rc1
- v0.13.1
- v0.13.0
- v0.13.0-rc2
- v0.13.0-rc1
- v0.12.1
- v0.12.0
- v0.12.0-rc2
- v0.12.0-rc1
- v0.11.2
- v0.11.1
- v0.11.0
- v0.11.0-rc2
- v0.11.0-rc1
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.10.0-rc3
- v0.10.0-rc2
- v0.10.0-rc1
- v0.9.1
- v0.9.0
- v0.9.0-rc2
- v0.9.0-rc1
- v0.8.2
- v0.8.1
- v0.8.0
- v0.8.0-rc1
Showing
7 changed files
with
157 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package logutil | ||
|
||
import ( | ||
"io/ioutil" | ||
"strings" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func NewFilter(filters ...string) logrus.Hook { | ||
dl := logrus.New() | ||
dl.SetOutput(ioutil.Discard) | ||
return &logsFilter{ | ||
filters: filters, | ||
discardLogger: dl, | ||
} | ||
} | ||
|
||
type logsFilter struct { | ||
filters []string | ||
discardLogger *logrus.Logger | ||
} | ||
|
||
func (d *logsFilter) Levels() []logrus.Level { | ||
return []logrus.Level{logrus.DebugLevel} | ||
} | ||
|
||
func (d *logsFilter) Fire(entry *logrus.Entry) error { | ||
for _, f := range d.filters { | ||
if strings.Contains(entry.Message, f) { | ||
entry.Logger = d.discardLogger | ||
return nil | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package logutil | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"sync" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func Pause(l *logrus.Logger) func() { | ||
// initialize formatter with original terminal settings | ||
l.Formatter.Format(logrus.NewEntry(l)) | ||
|
||
bw := newBufferedWriter(l.Out) | ||
l.SetOutput(bw) | ||
return func() { | ||
bw.resume() | ||
} | ||
} | ||
|
||
type bufferedWriter struct { | ||
mu sync.Mutex | ||
buf *bytes.Buffer | ||
w io.Writer | ||
} | ||
|
||
func newBufferedWriter(w io.Writer) *bufferedWriter { | ||
return &bufferedWriter{ | ||
buf: bytes.NewBuffer(nil), | ||
w: w, | ||
} | ||
} | ||
|
||
func (bw *bufferedWriter) Write(p []byte) (int, error) { | ||
bw.mu.Lock() | ||
defer bw.mu.Unlock() | ||
if bw.buf == nil { | ||
return bw.w.Write(p) | ||
} | ||
return bw.buf.Write(p) | ||
} | ||
|
||
func (bw *bufferedWriter) resume() { | ||
bw.mu.Lock() | ||
defer bw.mu.Unlock() | ||
if bw.buf == nil { | ||
return | ||
} | ||
io.Copy(bw.w, bw.buf) | ||
bw.buf = nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters