diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-02-19 12:01:27 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-02-19 12:01:27 +0200 |
commit | ed7ca4c631ff1c80a2c9bc34150ba97227ed13b2 (patch) | |
tree | 5f8384f42a482768152e6bc039ec7d8977978017 /workerpool.go | |
parent | Issue #14: Added BodyGunzip helper method to Request to be consistent with Re... (diff) | |
download | fasthttp-ed7ca4c631ff1c80a2c9bc34150ba97227ed13b2.tar.gz fasthttp-ed7ca4c631ff1c80a2c9bc34150ba97227ed13b2.tar.bz2 fasthttp-ed7ca4c631ff1c80a2c9bc34150ba97227ed13b2.zip |
Added LogAllErrors config parameter to Server, which allows logging the most frequent errors such as 'connection reset by peer', 'broken pipe' and 'i/o timeout'. By default such errors are suppressed
Diffstat (limited to 'workerpool.go')
-rw-r--r-- | workerpool.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/workerpool.go b/workerpool.go index 931ab35..03aee88 100644 --- a/workerpool.go +++ b/workerpool.go @@ -19,10 +19,10 @@ type workerPool struct { // It must leave c unclosed. WorkerFunc func(c net.Conn) error - // Maximum number of workers to create. MaxWorkersCount int - // Logger used by workerPool. + LogAllErrors bool + Logger Logger lock sync.Mutex @@ -194,8 +194,9 @@ func (wp *workerPool) workerFunc(ch *workerChan) { } if err = wp.WorkerFunc(c); err != nil && err != errHijacked { errStr := err.Error() - if !strings.Contains(errStr, "broken pipe") && !strings.Contains(errStr, "reset by peer") && - !strings.Contains(errStr, "i/o timeout") { + if wp.LogAllErrors || !(strings.Contains(errStr, "broken pipe") || + strings.Contains(errStr, "reset by peer") || + strings.Contains(errStr, "i/o timeout")) { wp.Logger.Printf("error when serving connection %q<->%q: %s", c.LocalAddr(), c.RemoteAddr(), err) } } |