elasticsearch

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package elasticsearch is a wrapper of the original "github.com/elastic/go-elasticsearch".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is elasticsearch client.

func New

func New(cfg Config) (*Client, error)

New to create new elasticsearch client.

func (*Client) Debug

func (c *Client) Debug(str string, args ...interface{})

Debug to print debug log.

func (*Client) Error

func (c *Client) Error(str string, args ...interface{})

Error to print error log.

func (*Client) Fatal

func (c *Client) Fatal(str string, args ...interface{})

Fatal to print fatal log. Will exit the program when called.

func (*Client) Info

func (c *Client) Info(str string, args ...interface{})

Info to print info log.

func (*Client) Log

func (c *Client) Log(fields map[string]interface{})

Log to print general log. Key `level` can be used to differentiate log level.

func (*Client) Panic

func (c *Client) Panic(str string, args ...interface{})

Panic to print panic log. Will print panic error stack and exit like panic().

func (*Client) Trace

func (c *Client) Trace(str string, args ...interface{})

Trace to print trace log.

func (*Client) Warn

func (c *Client) Warn(str string, args ...interface{})

Warn to print warn log.

type Config

type Config struct {
	Addresses []string
	Username  string
	Password  string
	Level     LogLevel

	// Will be formatted to include
	// current date.
	// Ex: logs-app => logs-app-YYYY-MM-DD
	Index string

	// Turn it on if you are logging
	// cron so it will wait until
	// sending the log to elasticseach
	// successfully before exiting app.
	IsSync bool
}

Config is elasticsearch config.

type LogLevel

type LogLevel int8

LogLevel is level of log that will be printed. Will print level that is higher than your chosen one.

const (
	TraceLevel LogLevel = iota - 1
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
	PanicLevel
	Disabled
)

Available log levec.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL