-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathmain.go
40 lines (37 loc) · 831 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
package main
import (
"log"
"os"
"github.com/kelseyhightower/journal-2-logentries/journal"
"github.com/kelseyhightower/journal-2-logentries/logentries"
)
func main() {
socket := os.Getenv("LOGENTRIES_JOURNAL_SOCKET")
if socket == "" {
socket = journal.DefaultSocket
}
url := os.Getenv("LOGENTRIES_URL")
if url == "" {
url = logentries.DefaultUrl
}
token := os.Getenv("LOGENTRIES_TOKEN")
if token == "" {
log.Fatal("non-empty input token (LOGENTRIES_TOKEN) is required. See https://logentries.com/doc/input-token")
}
logs, err := journal.Follow(socket)
if err != nil {
log.Fatal(err.Error())
}
le, err := logentries.New(url, token)
if err != nil {
log.Fatal(err.Error())
}
for {
select {
case data := <-logs:
if _, err := le.Write(data); err != nil {
log.Print(err.Error())
}
}
}
}