Documentation ¶
Index ¶
- Constants
- func ConvertToValue(p interface{}, tagName string) interface{}
- func FilterError(v interface{}) interface{}
- type Config
- type FluentHook
- func (hook *FluentHook) AddCustomizer(fn func(entry *logrus.Entry, data logrus.Fields))
- func (hook *FluentHook) AddFilter(name string, fn func(interface{}) interface{})
- func (hook *FluentHook) AddIgnore(name string)
- func (hook *FluentHook) Fire(entry *logrus.Entry) error
- func (hook *FluentHook) Levels() []logrus.Level
- func (hook *FluentHook) SetLevels(levels []logrus.Level)
- func (hook *FluentHook) SetMessageField(messageField string)
- func (hook *FluentHook) SetTag(tag string)
- func (hook *FluentHook) Tag() string
Constants ¶
const ( // TagName is struct field tag name. // Some basic option is allowed in the field tag, // // type myStruct { // Value1: `fluent:"value_1"` // change field name. // Value2: `fluent:"-"` // always omit this field. // Value3: `fluent:",omitempty"` // omit this field when zero-value. // } TagName = "fluent" // TagField is logrus field name used as fluentd tag TagField = "tag" // MessageField is logrus field name used as message. // If missing in the log fields, entry.Message is set to this field. MessageField = "message" )
Variables ¶
This section is empty.
Functions ¶
func ConvertToValue ¶
func ConvertToValue(p interface{}, tagName string) interface{}
ConvertToValue make map data from struct and tags
func FilterError ¶
func FilterError(v interface{}) interface{}
FilterError is a filter function to convert error type to string type.
Types ¶
type Config ¶ added in v0.4.0
type Config struct { Port int Host string LogLevels []logrus.Level DisableConnectionPool bool // Fluent client will be created every logging if true. DefaultTag string DefaultMessageField string DefaultIgnoreFields map[string]struct{} DefaultFilters map[string]func(interface{}) interface{} // from fluent.Config // see https://github.com/fluent/fluent-logger-golang/blob/master/fluent/fluent.go FluentNetwork string FluentSocketPath string Timeout time.Duration WriteTimeout time.Duration BufferLimit int RetryWait int MaxRetry int TagPrefix string AsyncConnect bool MarshalAsJSON bool SubSecondPrecision bool RequestAck bool }
Config is settings for FluentHook.
func (Config) FluentConfig ¶ added in v0.4.0
FluentConfig converts data to fluent.Config.
type FluentHook ¶
type FluentHook struct { // Fluent is actual fluentd logger. // If set, this logger is used for logging. // otherwise new logger is created every time. Fluent *fluent.Fluent // contains filtered or unexported fields }
FluentHook is logrus hook for fluentd.
func New ¶
func New(host string, port int) (*FluentHook, error)
New returns initialized logrus hook for fluentd with persistent fluentd logger.
func NewHook ¶
func NewHook(host string, port int) *FluentHook
NewHook returns initialized logrus hook for fluentd. (** deperecated: use New() or NewWithConfig() **)
func NewWithConfig ¶ added in v0.4.0
func NewWithConfig(conf Config) (*FluentHook, error)
NewWithConfig returns initialized logrus hook by config setting.
func (*FluentHook) AddCustomizer ¶ added in v0.5.4
func (hook *FluentHook) AddCustomizer(fn func(entry *logrus.Entry, data logrus.Fields))
AddCustomizer adds a custom function to modify data.
func (*FluentHook) AddFilter ¶
func (hook *FluentHook) AddFilter(name string, fn func(interface{}) interface{})
AddFilter adds a custom filter function.
func (*FluentHook) AddIgnore ¶
func (hook *FluentHook) AddIgnore(name string)
AddIgnore adds field name to ignore.
func (*FluentHook) Fire ¶
func (hook *FluentHook) Fire(entry *logrus.Entry) error
Fire is invoked by logrus and sends log to fluentd logger.
func (*FluentHook) Levels ¶
func (hook *FluentHook) Levels() []logrus.Level
Levels returns logging level to fire this hook.
func (*FluentHook) SetLevels ¶
func (hook *FluentHook) SetLevels(levels []logrus.Level)
SetLevels sets logging level to fire this hook.
func (*FluentHook) SetMessageField ¶ added in v0.3.1
func (hook *FluentHook) SetMessageField(messageField string)
SetMessageField sets custom message field.
func (*FluentHook) SetTag ¶
func (hook *FluentHook) SetTag(tag string)
SetTag sets custom static tag to override tag in the message fields.