A Golang library for fluent that implements the standard writer io interface.
go get go.gllm.dev/fluentio
package main
import (
"fmt"
"go.gllm.dev/fluentio"
)
func main() {
// Create a new fluentio.Writer
f, err := fluentio.New(fluentio.WithBasicConfig("127.0.0.1", 24224, true))
if err != nil {
os.Exit(1)
}
// Write to fluent
log := `{"message": "Hello World!"}`
i, err := f.Write([]byte(log))
if err != nil {
os.Exit(1)
}
fmt.Printf("Wrote %d bytes to fluent", i)
}
The fluentio.Writer can be configured with the following options:
// WithBasicConfig creates a new fluentio.Writer with a basic configuration
fluentio.New(fluentio.WithBasicConfig("127.0.0.1", 24224, true))
// WithFluentConfig creates a new fluentio.Writer with a standard fluent Config
// See github.com/fluent/fluent-logger-golang for more information
fluentio.New(fluentio.WithFluentConfig(fluent.Config{
FluentPort: 24224,
FluentHost: "127.0.0.1",
Async: true,
BufferLimit: 1024,
Timeout: 3 * time.Second,
// ...
}))
// WithTag sets the tag for the fluentio.Writer
fluentio.New(fluentio.WithTag("my.tag"))
This library depends on the following libraries:
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.