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
|
package main
import (
"fmt"
"log"
"time"
"../fluent"
)
func main() {
logger, err := fluent.New(fluent.Config{FluentPort: 24224, FluentHost: "127.0.0.1"})
if err != nil {
fmt.Println(err)
}
defer logger.Close()
tag := "myapp.access"
var data = map[string]string{
"foo": "bar",
"hoge": "hoge"}
for i := 0; i < 100; i++ {
e := logger.Post(tag, data)
if e != nil {
log.Println("Error while posting log: ", e)
} else {
log.Println("Success to post log")
}
time.Sleep(1000 * time.Millisecond)
}
}
|