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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?