🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

gopkg.in/airbrake/glog.v2

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gopkg.in/airbrake/glog.v2

Go
Version
v2.0.8
Version published
Created
Source

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"

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

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.Gobrake = 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.GobrakeSeverity = "WARNING"

FAQs

Package last updated on 12 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts