# README
Xlog
E[X]tend [Log]rus is Wrapper function for use logrus as builder design pattern and intergrate to elasticsearch in one line of code.
Geting Started
go get github.com/pepodev/xlog
Example
Just import and then use it
package main
import (
"github.com/pepodev/xlog"
)
func main(){
xlog.Trace("Trace")
xlog.Debug("Debug")
xlog.Info("Info")
xlog.Warn("Warn")
xlog.Error("Error")
xlog.Panic("Panic")
xlog.Fatal("Fatal")
}
Use with Elasticserch Hook
package main
import (
"github.com/pepodev/xlog"
)
func main(){
xlog.ConnectElasticsearch("http://localhost:9200", "username", "password", "host", "index", logrus.DebugLevel)
xlog.Info("HI Elasticsearch from XLog <3")
}
Use builder design pattern
package main
import (
"github.com/pepodev/xlog"
)
func main(){
xlog.ConnectElasticsearch("http://localhost:9200", "username", "password", "host", "index", logrus.DebugLevel)
log := xlog.NewLog()
log.SetField("SomeKey", "SomeValue").Info("HI Elasticsearch from XLog <3")
}
Depenencies
# Functions
ConnectElasticsearch will add Hook to logrus and push log in async mode to elasticsearch.
Debug will log in Debug level.
Debugf will log in Debug level with format.
Debugln will log in Debug level with format.
DefaultLogFormatter set Formatter with TextFormatter that log like.
Error will log in Error level.
Errorf will log in Error level with format.
Errorln will log in Error level with format.
Fatal will log in Fail level and call exit program.
Fatalf will log in Fail level with format and call exit program.
Fatalln will log in Fail level with format and call exit program.
GetFormatter return Formatter that use by log for do mini custom by yourself.
GetLevel returns the standard logger level.
Info will log in info level.
Infof will log in info level with format.
Infoln will log in info level with format.
NewLog Return new log struct.
Panic will log in panic level and call panic.
Panicf will log in panic level with format and call panic.
Panicln will log in panic level with format and call panic.
SetFormatter custom logrus Formatter.
SetLevel will set logrus level.
Trace will log in Trace level.
Tracef will log in Trace level with format.
Traceln will log in Trace level with format.
Warn will log in Warning level.
Warnf will log in Warning level with format.
Warnln will log in Warning level with format.