Skip to content

joshuasprow/eslogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElasticSearch Logger

This is a golang package that sends logs to an ElasticSearch instance through a custom zerolog transport.

Basic Usage (with zerolog integration)

package main

import (
	"github.com/joshuasprow/eslogger"
	"github.com/rs/zerolog/log"
)

func main() {
	conf := eslogger.Config{
		Index: "test-index", // Will be appended with "-year-month-date"
		Addresses: []string{
			"http://localhost:9200",
			"http://localhost:9201",
		},
		Username: "me",
		Password: "supersecretpassword",
		Headers: map[string]string{
			"Auth-Client-Id":     "stringofnastycharacters",
			"Auth-Client-Secret": "stringofnastycharacters",
		},
	}

	logger, err := eslogger.New(conf)
	if err != nil {
		log.Fatal().Err(err).Msg("failed to initialize logger")
	}

	log.Logger = logger

	log.Info().Msg("I'm logging to ElasticSearch!")
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages