formatter

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 9 Imported by: 0

README

logrus-utils-formatter

  • github.com/go-errors/errors wrap stacktrace format full stacktrace will only work under log.DebugLevel
  • xerrors error trace format
  • OpenTracing span Context LogFields
    • Error Report with StackTrace and detail from log.Error()
    • Caller info if log.SetReportCaller(true)
package main
import (
    "github.com/LaysDragon/logrus-utils-formatter"
    "github.com/gin-gonic/gin"
    log "github.com/sirupsen/logrus"
)

func init(){
	log.SetFormatter(&formatter.ErrorStracktraceTextFormatter{})
    log.SetReportCaller(true)
    log.SetLevel(log.InfoLevel)
}



func GinHandler(c *gin.Context) {
	log := log.WithContext(c) //c.Request.Context() contain OpenTracing span data
	if err:= DoSomeghing();err!= nil{
        log.WithError(err).WithError(err).Error("error happen while ...")
    }
    
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UtilsFormatter added in v0.0.3

type UtilsFormatter struct {
	log.TextFormatter
}

func (*UtilsFormatter) Format added in v0.0.3

func (f *UtilsFormatter) Format(entry *log.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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