gobrake

package module
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2015 License: BSD-3-Clause Imports: 13 Imported by: 39

README

Airbrake Golang Notifier Build Status

Example

package main

import (
	"errors"

	"gopkg.in/airbrake/gobrake.v2"
)

var airbrake = gobrake.NewNotifier(1234567, "FIXME")

func init() {
	airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
		notice.Context["environment"] = "production"
		return notice
	})
}

func main() {
	defer func() {
		if v := recover(); v != nil {
			airbrake.Notify(v, nil)
			panic(v)
		}
	}()
	defer airbrake.Flush()

	airbrake.Notify(errors.New("operation failed"), nil)
}

Ignoring notices

airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
	if notice.Context["environment"] == "development" {
		// Ignore notices in development environment.
		return nil
	}
	return notice
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Type      string       `json:"type"`
	Message   string       `json:"message"`
	Backtrace []StackFrame `json:"backtrace"`
}

type Notice

type Notice struct {
	Notifier notifier               `json:"notifier"`
	Errors   []Error                `json:"errors"`
	Context  map[string]string      `json:"context"`
	Env      map[string]interface{} `json:"environment"`
	Session  map[string]interface{} `json:"session"`
	Params   map[string]interface{} `json:"params"`
}

func NewNotice

func NewNotice(e interface{}, req *http.Request, depth int) *Notice

type Notifier

type Notifier struct {
	Client *http.Client
	// contains filtered or unexported fields
}

func NewNotifier

func NewNotifier(projectId int64, projectKey string) *Notifier

func (*Notifier) AddFilter

func (n *Notifier) AddFilter(fn filter)

AddFilter adds filter that can modify or ignore notice.

func (*Notifier) Flush

func (n *Notifier) Flush()

Flush flushes all pending I/O.

func (*Notifier) Notice

func (n *Notifier) Notice(err interface{}, req *http.Request, depth int) *Notice

Notice returns Aibrake notice created from error and request. depth determines which call frame to use.

func (*Notifier) Notify

func (n *Notifier) Notify(e interface{}, req *http.Request)

Notify notifies Airbrake about the error.

func (*Notifier) SendNotice

func (n *Notifier) SendNotice(notice *Notice) (string, error)

SendNotice sends notice to Airbrake.

func (*Notifier) SetHost

func (n *Notifier) SetHost(h string)

Sets Airbrake host name. Default is https://airbrake.io.

type StackFrame

type StackFrame struct {
	File string `json:"file"`
	Line int    `json:"line"`
	Func string `json:"function"`
}

Directories

Path Synopsis
beego module
gin module
negroni module

Jump to

Keyboard shortcuts

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