Skip to content

Commit

Permalink
Fix duplicating base directory for file create event (grafana#128)
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Kovetskiy <[email protected]>
  • Loading branch information
kovetskiy authored and tomwilkie committed Dec 16, 2018
1 parent 251017e commit 4d78e16
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/promtail/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewTarget(logger log.Logger, handler EntryHandler, positions *Positions, pa
continue
}

tailer, err := newTailer(t.logger, t.handler, t.positions, t.path, fi.Name())
tailer, err := newTailer(t.logger, t.handler, t.positions, filepath.Join(t.path, fi.Name()))
if err != nil {
level.Error(t.logger).Log("msg", "failed to tail file", "error", err)
continue
Expand Down Expand Up @@ -115,7 +115,7 @@ func (t *Target) run() {
continue
}

tailer, err := newTailer(t.logger, t.handler, t.positions, t.path, event.Name)
tailer, err := newTailer(t.logger, t.handler, t.positions, event.Name)
if err != nil {
level.Error(t.logger).Log("msg", "failed to tail file", "error", err)
continue
Expand Down Expand Up @@ -150,8 +150,7 @@ type tailer struct {
tail *tail.Tail
}

func newTailer(logger log.Logger, handler EntryHandler, positions *Positions, dir, name string) (*tailer, error) {
path := filepath.Join(dir, name)
func newTailer(logger log.Logger, handler EntryHandler, positions *Positions, path string) (*tailer, error) {
tail, err := tail.TailFile(path, tail.Config{
Follow: true,
Location: &tail.SeekInfo{
Expand Down

0 comments on commit 4d78e16

Please sign in to comment.