fluent-logger-golang

A structured logger for Fluentd (Golang)

Github星跟踪图

fluent-logger-golang

Build Status
GoDoc

A structured event logger for Fluentd (Golang)

How to install

go get github.com/fluent/fluent-logger-golang/fluent

Usage

Install the package with go get and use import to include it in your project.

import "github.com/fluent/fluent-logger-golang/fluent"

Example

package main

import (
  "github.com/fluent/fluent-logger-golang/fluent"
  "fmt"
  //"time"
)

func main() {
  logger, err := fluent.New(fluent.Config{})
  if err != nil {
    fmt.Println(err)
  }
  defer logger.Close()
  tag := "myapp.access"
  var data = map[string]string{
    "foo":  "bar",
    "hoge": "hoge",
  }
  error := logger.Post(tag, data)
  // error := logger.PostWithTime(tag, time.Now(), data)
  if error != nil {
    panic(error)
  }
}

data must be a value like map[string]literal, map[string]interface{}, struct or msgp.Marshaler. Logger refers tags msg or codec of each fields of structs.

Setting config values

f := fluent.New(fluent.Config{FluentPort: 80, FluentHost: "example.com"})

WriteTimeout

Sets the timeout for Write call of logger.Post.
Since the default is zero value, Write will not time out.

Async

Enable asynchronous I/O (connect and write) for sending events to Fluentd.
The default is false.

ForceStopAsyncSend

When Async is enabled, immediately discard the event queue on close() and return (instead of trying MaxRetry times for each event in the queue before returning)
The default is false.

RequestAck

Sets whether to request acknowledgment from Fluentd to increase the reliability
of the connection. The default is false.

FAQ

Does this logger support the features of Fluentd Forward Protocol v1?

"the features" includes heartbeat messages (for TCP keepalive), TLS transport and shared key authentication.

This logger doesn't support those features. Patches are welcome!

Tests

go test

主要指标

概览
名称与所有者fluent/fluent-logger-golang
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证Apache License 2.0
所有者活动
创建于2013-04-10 05:56:04
推送于2023-09-11 10:25:53
最后一次提交2021-12-22 21:28:33
发布数33
最新版本名称v1.9.0 (发布于 2021-12-22 21:31:44)
第一版名称v0.0.1 (发布于 2013-04-10 17:09:33)
用户参与
星数391
关注者数18
派生数104
提交数246
已启用问题?
问题数52
打开的问题数18
拉请求数51
打开的拉请求数4
关闭的拉请求数22
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?