log

package module
v0.0.0-...-75a2b95 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2015 License: MIT Imports: 11 Imported by: 0

README

go-sentry-logger

Go logger with sentry

this supports logging error data and send it to sentry.

Configure

set sentry's dsn

vim log.json

{
    "sentry": "https://<your key>@app.getsentry.com/<your id>",
}

Quick Usage

import(
    log "github.com/evalphobia/go-sentry-logger"
)

func main(){
    _, err := someFunction() // dummy code

    if err != nil {
        e := log.NewData(err, 0) // log.NewData(any data, stack trace depth)
        e.Label = "[ERROR] unknown error occured"
        e.Request = req // set *http.Request

        log.Fatal(err) // logging & send data to senty
        log.Error(err) // logging & send data to senty
        log.Warn(err)  // logging & send data to senty
        log.Info(err)  // do NOT send data to senty
        log.Debug(err) // do NOT send data to senty
        
        log.SentryLevel = 4 // default 3
        log.Fatal(err) // logging & send data to senty, level=5
        log.Error(err) // logging & send data to senty, level=4
        log.Warn(err)  // do NOT send data to senty, level=3
    }
    
    // use for print debugging, 
    log.PrintHeader("!!debug data!!")
    log.Print(err, 0)
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Logger Loggers

	SentryLevel int
)

Functions

func Debug

func Debug(l *LogData)

logging debug infomation

func Error

func Error(l *LogData)

logging high level error

func ErrorWithoutTrack

func ErrorWithoutTrack(l *LogData)

logging error without sentry

func Fatal

func Fatal(l *LogData)

logging fatal error

func HasPointer

func HasPointer(typeName string) bool

check if the typename has pointer

func Info

func Info(l *LogData)

logging infomation

func ParseToString

func ParseToString(v Any) string

return value

func ParseToType

func ParseToType(v Any) string

return type name

func Print

func Print(v Any, depth int)

print infomation with the logging format

func PrintHeader

func PrintHeader(v ...Any)

print header

func SendSentry

func SendSentry(args map[string]string, label string, req *http.Request, e error)

send data to sentry

func SendSentryMapData

func SendSentryMapData(args map[string]string, req *http.Request, e error)

func SetConfig

func SetConfig(conf Config)

get parameter from config file

func SetDefaultConfig

func SetDefaultConfig()

func SetDefaultLogger

func SetDefaultLogger()

func Warn

func Warn(l *LogData)

logging middle level error

Types

type Any

type Any interface{}

the type for anything

type Config

type Config interface {
	// params(filename, section, key, defaultValue)
	GetConfigValueDefault(string, string, string) string

	// params(filename, section, key)
	GetConfigValue(string, string) string
}

type DefaultConfig

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

func NewDefaultConfig

func NewDefaultConfig(path string) *DefaultConfig

func (*DefaultConfig) GetConfigValue

func (c *DefaultConfig) GetConfigValue(section, key string) string

func (*DefaultConfig) GetConfigValueDefault

func (c *DefaultConfig) GetConfigValueDefault(section, key, defaultValue string) string

get parameter from json file

type DefaultLogger

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

func (*DefaultLogger) GetLogger

func (l *DefaultLogger) GetLogger(name string) *log.Logger

type LogData

type LogData struct {
	Request *http.Request
	Label   string
	// contains filtered or unexported fields
}

func NewLogData

func NewLogData(data Any, depth int) *LogData

type Loggers

type Loggers interface {
	GetLogger(string) *log.Logger
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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