Documentation ¶
Index ¶
- Variables
- type ElasticHook
- func NewAsyncElasticHook(client *elasticsearch.Client, host string, level logrus.Level, index string) (*ElasticHook, error)
- func NewAsyncElasticHookWithFunc(client *elasticsearch.Client, host string, level logrus.Level, ...) (*ElasticHook, error)
- func NewBulkProcessorElasticHook(client *elasticsearch.Client, host string, level logrus.Level, index string) (*ElasticHook, error)
- func NewBulkProcessorElasticHookWithFunc(client *elasticsearch.Client, host string, level logrus.Level, ...) (*ElasticHook, error)
- func NewElasticHook(client *elasticsearch.Client, host string, level logrus.Level, index string) (*ElasticHook, error)
- func NewElasticHookWithFunc(client *elasticsearch.Client, host string, level logrus.Level, ...) (*ElasticHook, error)
- type IndexNameFunc
- type Message
- type ModifyMessageFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCannotCreateIndex Fired if the index is not created ErrCannotCreateIndex = fmt.Errorf("cannot create index") )
Functions ¶
This section is empty.
Types ¶
type ElasticHook ¶
type ElasticHook struct { // MessageModifierFunc is a function that can be called to create a // custom object to send to Elasticsearch for setting root fields // like "trace.id" or customizing other parts of the message MessageModifierFunc ModifyMessageFunc // contains filtered or unexported fields }
ElasticHook is a logrus hook for ElasticSearch
func NewAsyncElasticHook ¶
func NewAsyncElasticHook(client *elasticsearch.Client, host string, level logrus.Level, index string) (*ElasticHook, error)
NewAsyncElasticHook creates new hook with asynchronous log. client - ElasticSearch client with specific es version (v5/v6/v7/...) host - host of system level - log level index - name of the index in ElasticSearch
func NewAsyncElasticHookWithFunc ¶
func NewAsyncElasticHookWithFunc(client *elasticsearch.Client, host string, level logrus.Level, indexFunc IndexNameFunc) (*ElasticHook, error)
NewAsyncElasticHookWithFunc creates new asynchronous hook with function that provides the index name. This is useful if the index name is somehow dynamic especially based on time. client - ElasticSearch client with specific es version (v5/v6/v7/...) host - host of system level - log level indexFunc - function providing the name of index
func NewBulkProcessorElasticHook ¶
func NewBulkProcessorElasticHook(client *elasticsearch.Client, host string, level logrus.Level, index string) (*ElasticHook, error)
NewBulkProcessorElasticHook creates new hook that uses a bulk processor for indexing. client - ElasticSearch client with specific es version (v5/v6/v7/...) host - host of system level - log level index - name of the index in ElasticSearch
func NewBulkProcessorElasticHookWithFunc ¶
func NewBulkProcessorElasticHookWithFunc(client *elasticsearch.Client, host string, level logrus.Level, indexFunc IndexNameFunc) (*ElasticHook, error)
NewBulkProcessorElasticHookWithFunc creates new hook with function that provides the index name. This is useful if the index name is somehow dynamic especially based on time that uses a bulk processor for indexing. client - ElasticSearch client with specific es version (v5/v6/v7/...) host - host of system level - log level indexFunc - function providing the name of index
func NewElasticHook ¶
func NewElasticHook(client *elasticsearch.Client, host string, level logrus.Level, index string) (*ElasticHook, error)
NewElasticHook creates new hook. client - ElasticSearch client with specific es version (v5/v6/v7/...) host - host of system level - log level index - name of the index in ElasticSearch
func NewElasticHookWithFunc ¶
func NewElasticHookWithFunc(client *elasticsearch.Client, host string, level logrus.Level, indexFunc IndexNameFunc) (*ElasticHook, error)
NewElasticHookWithFunc creates new hook with function that provides the index name. This is useful if the index name is somehow dynamic especially based on time. client - ElasticSearch client with specific es version (v5/v6/v7/...) host - host of system level - log level indexFunc - function providing the name of index
func (*ElasticHook) Fire ¶
func (hook *ElasticHook) Fire(entry *logrus.Entry) error
Fire is required to implement Logrus hook
func (*ElasticHook) Levels ¶
func (hook *ElasticHook) Levels() []logrus.Level
Levels Required for logrus hook implementation
type ModifyMessageFunc ¶ added in v7.3.0
ModifyMessageFunc is a function that can be used to generate the object sent to elasticsearch. The output value should be useable by json.Marshal