Skip to content

Commit

Permalink
index function evaluated in time of fire
Browse files Browse the repository at this point in the history
  • Loading branch information
sohlich committed Dec 19, 2017
1 parent bccae70 commit 2baf900
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (

type IndexNameFunc func() string

type fireFunc func(entry *logrus.Entry, hook *ElasticHook) error
type fireFunc func(entry *logrus.Entry, hook *ElasticHook, indexName string) error

// ElasticHook is a logrus
// hook for ElasticSearch
Expand Down Expand Up @@ -120,15 +120,15 @@ func newHookFuncAndFireFunc(client *elastic.Client, host string, level logrus.Le
// Fire is required to implement
// Logrus hook
func (hook *ElasticHook) Fire(entry *logrus.Entry) error {
return hook.fireFunc(entry, hook)
return hook.fireFunc(entry, hook, hook.index())
}

func asyncFireFunc(entry *logrus.Entry, hook *ElasticHook) error {
go syncFireFunc(entry, hook)
func asyncFireFunc(entry *logrus.Entry, hook *ElasticHook, indexName string) error {
go syncFireFunc(entry, hook, hook.index())
return nil
}

func syncFireFunc(entry *logrus.Entry, hook *ElasticHook) error {
func syncFireFunc(entry *logrus.Entry, hook *ElasticHook, indexName string) error {
level := entry.Level.String()

if e, ok := entry.Data[logrus.ErrorKey]; ok && e != nil {
Expand Down

0 comments on commit 2baf900

Please sign in to comment.