diff --git a/.travis.yml b/.travis.yml index 8bc6fd6..f27cb8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_install: - mysql -e 'CREATE DATABASE myapp_test;' - go get -t -v ./... script: - - go test -coverprofile=coverage.txt -covermode=atomic + - go test -race -coverprofile=coverage.txt -covermode=atomic after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/hook.go b/hook.go index 750efb0..9858d84 100644 --- a/hook.go +++ b/hook.go @@ -21,12 +21,15 @@ var defaultOptions = options{ }, } +// FilterHandle a filter handler +type FilterHandle func(*logrus.Entry) *logrus.Entry + type options struct { maxQueues int maxWorkers int extra map[string]interface{} exec Execer - filter func(*logrus.Entry) *logrus.Entry + filter FilterHandle levels []logrus.Level out io.Writer } @@ -60,7 +63,7 @@ func SetExec(exec Execer) Option { } // SetFilter set the entry filter -func SetFilter(filter func(*logrus.Entry) *logrus.Entry) Option { +func SetFilter(filter FilterHandle) Option { return func(o *options) { o.filter = filter } diff --git a/job.go b/job.go index b3e76f5..77b4af8 100644 --- a/job.go +++ b/job.go @@ -12,10 +12,18 @@ type job struct { entry *logrus.Entry exec Execer extra map[string]interface{} - filter func(*logrus.Entry) *logrus.Entry + filter FilterHandle } -func (j *job) Reset(entry *logrus.Entry) { +func (j *job) Reset(e *logrus.Entry) { + entry := logrus.NewEntry(e.Logger) + entry.Data = make(logrus.Fields) + entry.Time = e.Time + entry.Level = e.Level + entry.Message = e.Message + for k, v := range e.Data { + entry.Data[k] = v + } j.entry = entry }