Skip to content

Commit ddf124b

Browse files
authored
Replace github.com/hpcloud/tail with github.com/papertrail/ptail (#188)
* Replace github.com/hpcloud/tail with github.com/papertrail/ptail * rename tailing package * Close the tailing watcher when exiting tail loop * remove binary * revert test debug
1 parent dde03a5 commit ddf124b

39 files changed

+279
-3935
lines changed

remote_syslog.go

+15-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/howbazaar/loggo"
16-
"github.com/hpcloud/tail"
16+
"github.com/papertrail/go-tail/follower"
1717
"github.com/papertrail/remote_syslog2/syslog"
1818
"github.com/papertrail/remote_syslog2/utils"
1919
)
@@ -100,12 +100,10 @@ func (s *Server) closing() bool {
100100
func (s *Server) tailOne(file, tag string, whence int) {
101101
defer s.registry.Remove(file)
102102

103-
t, err := tail.TailFile(file, tail.Config{
104-
ReOpen: true,
105-
Follow: true,
106-
MustExist: true,
107-
Poll: s.config.Poll,
108-
Location: &tail.SeekInfo{0, whence},
103+
t, err := follower.New(file, follower.Config{
104+
Reopen: true,
105+
Offset: 0,
106+
Whence: whence,
109107
})
110108

111109
if err != nil {
@@ -119,33 +117,36 @@ func (s *Server) tailOne(file, tag string, whence int) {
119117

120118
for {
121119
select {
122-
case line := <-t.Lines:
120+
case line := <-t.Lines():
123121
if s.closing() {
122+
t.Close()
124123
return
125124
}
126125

127-
if !matchExps(line.Text, s.config.ExcludePatterns) {
126+
l := line.String()
127+
128+
if !matchExps(l, s.config.ExcludePatterns) {
129+
128130
s.logger.Write(syslog.Packet{
129131
Severity: s.config.Severity,
130132
Facility: s.config.Facility,
131133
Time: time.Now(),
132134
Hostname: s.logger.ClientHostname,
133135
Tag: tag,
134-
Message: line.Text,
136+
Message: l,
135137
})
136138

137-
log.Tracef("Forwarding line: %s", line.Text)
139+
log.Tracef("Forwarding line: %s", l)
138140

139141
} else {
140-
log.Tracef("Not Forwarding line: %s", line.Text)
142+
log.Tracef("Not Forwarding line: %s", l)
141143
}
142144

143145
case <-s.stopChan:
146+
t.Close()
144147
return
145148
}
146149
}
147-
148-
return
149150
}
150151

151152
// Tails files speficied in the globs and re-evaluates the globs

vendor/github.com/hpcloud/tail/CHANGES.md

-63
This file was deleted.

vendor/github.com/hpcloud/tail/Dockerfile

-19
This file was deleted.

vendor/github.com/hpcloud/tail/LICENSE.txt

-21
This file was deleted.

vendor/github.com/hpcloud/tail/Makefile

-11
This file was deleted.

vendor/github.com/hpcloud/tail/README.md

-28
This file was deleted.

vendor/github.com/hpcloud/tail/appveyor.yml

-11
This file was deleted.

vendor/github.com/hpcloud/tail/ratelimiter/Licence

-7
This file was deleted.

vendor/github.com/hpcloud/tail/ratelimiter/leakybucket.go

-97
This file was deleted.

vendor/github.com/hpcloud/tail/ratelimiter/memory.go

-58
This file was deleted.

0 commit comments

Comments
 (0)