Documentation ¶
Overview ¶
Package fluentd exposes a class that adheres to the logrus.Hook interface. Create it, then add it to an existing logger using the .AddHook method of a logrus.Logger
Example initialization:
```go import ( "github.com/usvc/go-log/pkg/logger" "github.com/usvc/go-log/pkg/hooks/fluentd" "github.com/usvc/go-log/pkg/constants" ) // ... logger := logger.New() fluentHook := fluentd.NewHook(&fluenthook.HookConfig{ Host: "localhost", Port: 24224, InitializeRetryCount: 10, InitializeRetryInterval: time.Second * 1, Levels: constants.DefaultHookLevels, Tag: "tag", } logger.AddHook(fluentHook) ```
For the full guide visit https://gitlab.com/usvc/modules/go/log
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook implements the logrus.Hook interface
func NewHook ¶
func NewHook( config *HookConfig, logger ...Logger, ) *Hook
NewHook instantiates a new minimal fluentd hook given a configuration and an optional logger to use (if a logger is not provided, the in- built one will be used)
type HookConfig ¶
type HookConfig struct { // Host contains the hostname of the fluentd service // // example: "fluentd.monitoring.svc.cluster.local" Host string // Port contains the port that the fluentd service // is listening on // // example: 24224 Port int // InitializeRetryCount indicates how many times the // initialize() function should try to connect to the // fluentd service before it fails // // example: 10 InitializeRetryCount int // InitializeRetryInterval indicates the duration in // between connection attempts to fluentd by initialize() // // example: 5 * time.Second InitializeRetryInterval time.Duration // Levels is an array of logrus levels that the hook // should be activated for // // example: []logrus.Level{logrus.TraceLevel} Levels []logrus.Level // Tag defines the base tag used to tag the log entries // sent to fluentd // // example: "application" Tag string }
HookConfig stores the configuration for the Hook class and contains properties that will be used to initialise the Hook
func NewConfig ¶ added in v0.1.8
func NewConfig() *HookConfig
NewConfig returns a hook configuration with the default configuration