Git Product home page Git Product logo

glog's Introduction

Glog

This fork of https://github.com/golang/glog provides all of glog's functionality and adds the ability to send errors/logs to Airbrake.io.

Logging

Please refer to the glog code & docs.

Sending errors to Airbrake.io

A basic example of how to configure glog to send logged errors to Airbrake.io:

package main

import (
	"errors"

	"github.com/airbrake/glog/v4"
	"github.com/airbrake/gobrake/v4"
)

var projectId int64 = 123
var apiKey string = "API_KEY"

func doSomeWork() error {
	return errors.New("hello from Go")
}

func main() {
	airbrake := gobrake.NewNotifier(projectId, apiKey)
	defer airbrake.Close()
	defer airbrake.NotifyOnPanic()

	airbrake.AddFilter(func(n *gobrake.Notice) *gobrake.Notice {
		n.Context["environment"] = "production"
		return n
	})
	glog.SetGobrakeNotifier(airbrake)

	if err := doSomeWork(); err != nil {
		glog.Errorf("doSomeWork failed: %s", err)
	}
}

Configure severity

The default is to send only error logs to Airbrake.io. You can change the severity threshold to also send lower severity logs too, such as warnings:

glog.SetGobrakeSeverity("WARNING")

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.