Socket
Book a DemoInstallSign in
Socket

gopkg.in/go-extras/elogrus.v8

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gopkg.in/go-extras/elogrus.v8

v8.0.1
Go
Version published
Created
Source

Elasticsearch Hook for Logrus :walrus:

Intro

This is a hard fork of https://github.com/sohlich/elogrus. The original library used https://github.com/olivere/elastic, which is a non-official Elasticsearch go client. This fork uses the official client library.

Releases

This fork is designed to use the official Go client for Elasticsearch

Notice that the master branch always refers to the latest version of Elastic. If you want to use stable versions of elogus, you should use the packages released via gopkg.in.

Here's the version matrix:

Elasticsearch versionElastic Go Client versionPackage URLRemarks
7.x7.0gopkg.in/go-extras/elogrus.v7Actively maintained.
8.x8.0gopkg.in/go-extras/elogrus.v8Actively maintained.

For Elasticsearch 7.x

# We name v7 to align with elastic v7
go get github.com/elastic/go-elasticsearch/v7
go get gopkg.in/go-extras/elogrus.v7

For Elasticsearch 8.x

# We name v8 to align with elastic v8
go get github.com/elastic/go-elasticsearch/v8
go get gopkg.in/go-extras/elogrus.v8

Changelog

Usage

package main

import (
	"github.com/elastic/go-elasticsearch/v7"
	"github.com/sirupsen/logrus"
	"gopkg.in/go-extras/elogrus.v7"
)

func main() {
	log := logrus.New()
	client, err := elasticsearch.NewClient(elasticsearch.Config{
		Addresses: []string{"http://127.0.0.1:7777"},
	})
	if err != nil {
		log.Panic(err)
	}
	hook, err := elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
	if err != nil {
		log.Panic(err)
	}
	log.Hooks.Add(hook)
	log.WithFields(logrus.Fields{
		"name": "joe",
		"age":  42,
	}).Error("Hello world!")
}

Asynchronous hook

	...
	elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
	...

FAQs

Package last updated on 16 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.