Giter VIP home page Giter VIP logo

go.airbrake's Introduction

go.airbrake

go.airbrake provides airbrake v3 error logging functionality.

GoDoc

Installation

go get github.com/GeertJohan/go.airbrake

Usage

First, create a Brake:

brake := airbrake.NewBrake("projectID", "apiKey", "application environment", nil)

Then, use the brake when there is a problem:

brake.Error("household", "All the food is gone!")

Use Errorf for formatted strings (fmt.Sprintf shorthand):

roof := "roof"
fire := "fire!"
brake.Errorf("house-structure", "The %s is on %s", roof, fire)

Send data with your error:

brake.ErrorData("data-dump", "some error message here", airbrake.Data{
	Environment: airbrake.Vars{"GOPATH": os.Getenv("GOPATH")},
	Session:     airbrake.Vars{"AccountID": 1337},
	Params:      airbrake.Vars{
		"filename": "foo.bar",
		"object": airbrake.Vars{
			"foo": "bar",
			"number": 42,
		}
	},
})

You can also use the brake to recover from a panic

func doStuff() {
	defer brake.Recover()

	// do stuff

	// suddenly, a wild panic appears
	panic("oh noes! a panic!")
}

The deferred call to brake.Recover() recovers from the panic and sends the message to Airbrake.io. Error class will be "panic".

You can use the WrapHTTP* methods to wrap any http.Handler or http.HandlerFunc. This recovers the Handler/HandlerFunc from any panic.

//++ TODO, test and example

TODO

  • think about airb.at
  • make human log configurable (disable type, disable message, cap message to chars (0=infinite), disable url)
  • more TODO's in code

go.airbrake's People

Watchers

Sander avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.