Skip to content

Commit cda5b23

Browse files
author
rafael_chicoli
committed
docker: pass variables to Log func instead of object
1 parent 15d5621 commit cda5b23

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/docker/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (d *Driver) StartLogging(file string, info logger.Info) error {
9191
c.logger.WithError(err).Error("could not parse line message")
9292
}
9393

94-
if err := d.Log(pctx, file, config); err != nil {
94+
if err := d.Log(pctx, file, config.Bulk.workers, config.Bulk.actions, config.Bulk.size, config.Bulk.flushInterval, config.Bulk.stats, c.indexName, config.tzpe); err != nil {
9595
c.logger.WithError(err).Error("could not log to elasticsearch")
9696
}
9797

pkg/docker/pipeline.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"os"
99
"strings"
10+
"time"
1011

1112
"github.com/docker/docker/api/types/plugins/logdriver"
1213
protoio "github.com/gogo/protobuf/io"
@@ -132,7 +133,7 @@ func (d *Driver) Parse(ctx context.Context, file, fields, grokMatch, grokPattern
132133
}
133134

134135
// Log sends messages to Elasticsearch Bulk Service
135-
func (d *Driver) Log(ctx context.Context, file string, config Configuration) error {
136+
func (d *Driver) Log(ctx context.Context, file string, workers, actions, size int, flushInterval time.Duration, stats bool, indexName, tzpe string) error {
136137

137138
c, err := d.getContainer(file)
138139
if err != nil {
@@ -141,7 +142,7 @@ func (d *Driver) Log(ctx context.Context, file string, config Configuration) err
141142

142143
c.pipeline.group.Go(func() error {
143144

144-
err := c.esClient.NewBulkProcessorService(ctx, config.Bulk.workers, config.Bulk.actions, config.Bulk.size, config.Bulk.flushInterval, config.Bulk.stats)
145+
err = c.esClient.NewBulkProcessorService(ctx, workers, actions, size, flushInterval, stats)
145146
if err != nil {
146147
c.logger.WithError(err).Error("could not create bulk processor")
147148
}
@@ -159,7 +160,7 @@ func (d *Driver) Log(ctx context.Context, file string, config Configuration) err
159160

160161
for doc := range c.pipeline.outputCh {
161162

162-
c.esClient.Add(c.indexName, config.tzpe, doc)
163+
c.esClient.Add(indexName, tzpe, doc)
163164

164165
select {
165166
case <-ctx.Done():

0 commit comments

Comments
 (0)