• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

_examples/H26-May-2015-2521

fluent/H26-May-2015-1,2091,045

.gitignoreH A D26-May-201531 44

.travis.ymlH A D26-May-2015212 1413

CHANGELOG.mdH A D26-May-2015852 3424

LICENSEH A D26-May-2015553 1310

README.mdH A D26-May-20151.3 KiB6649

README.md

1fluent-logger-golang
2====
3
4[![Build Status](https://travis-ci.org/fluent/fluent-logger-golang.png?branch=master)](https://travis-ci.org/fluent/fluent-logger-golang)
5
6## A structured event logger for Fluentd (Golang)
7
8## How to install
9
10```
11go get github.com/fluent/fluent-logger-golang/fluent
12```
13
14## Usage
15
16Install the package with `go get` and use `import` to include it in your project.
17
18```
19import "github.com/fluent/fluent-logger-golang/fluent"
20```
21
22GoDoc: http://godoc.org/github.com/fluent/fluent-logger-golang/fluent
23
24##Example
25
26```go
27package main
28
29import (
30  "github.com/fluent/fluent-logger-golang/fluent"
31  "fmt"
32  "time"
33)
34
35func main() {
36  logger, err := fluent.New(fluent.Config{})
37  if err != nil {
38    fmt.Println(err)
39  }
40  defer logger.Close()
41  tag := "myapp.access"
42  var data = map[string]string{
43    "foo":  "bar",
44    "hoge": "hoge"
45  }
46  error := logger.Post(tag, data)
47  // error := logger.Post(tag, time.Time.Now(), data)
48  if error != nil {
49    panic(error)
50  }
51}
52```
53
54`data` must be a value like `map[string]literal`, `map[string]interface{}` or `struct`. Logger refers tags `msg` or `codec` of each fields of structs.
55
56## Setting config values
57
58```go
59f := fluent.New(fluent.Config{FluentPort: 80, FluentHost: "example.com"})
60```
61
62## Tests
63```
64go test
65```
66