Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
_examples/ | H | 26-May-2015 | - | 25 | 21 | |
fluent/ | H | 26-May-2015 | - | 1,209 | 1,045 | |
.gitignore | H A D | 26-May-2015 | 31 | 4 | 4 | |
.travis.yml | H A D | 26-May-2015 | 212 | 14 | 13 | |
CHANGELOG.md | H A D | 26-May-2015 | 852 | 34 | 24 | |
LICENSE | H A D | 26-May-2015 | 553 | 13 | 10 | |
README.md | H A D | 26-May-2015 | 1.3 KiB | 66 | 49 |
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