-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.go
41 lines (38 loc) · 732 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"os"
"github.com/fujiwara/fluent-agent-hydra/hydra"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage\ntail-f filename")
os.Exit(1)
}
filename, err := hydra.Rel2Abs(os.Args[1])
if err != nil {
panic(err)
}
watcher, err := hydra.NewWatcher()
if err != nil {
panic(err)
}
c := hydra.NewContext()
config := &hydra.ConfigLogfile{
Tag: "dummy",
File: filename,
FieldName: "message",
}
inTail, err := hydra.NewInTail(config, watcher)
c.RunProcess(inTail)
c.RunProcess(watcher)
for {
recordSet := <-c.MessageCh
for _, record := range recordSet.Records {
b, ok := record.GetData("message")
if ok {
fmt.Println(string(b.([]byte)))
}
}
}
}