GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - muravjov/slog

BranchesTags
Open more actions menu

Latest commit

 

History

57 Commits
57 Commits

Folders and files

NameName
Last commit message
Last commit date
base
base
 
 
httpstresser
httpstresser
 
 
launcher
launcher
 
 
sentry-prober
sentry-prober
 
 
sentry
sentry
 
 
slog-app
slog-app
 
 
stress
stress
 
 
v2
v2
 
 
watcher
watcher
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
slog.go
slog.go
 
 
slog_test.go
slog_test.go
 
 

Repository files navigation

Golang logging integration with Sentry

Package slog implements way to log to Sentry along with such a logging libraries as standard package log and go-logging. Also it provides a way to catch Golang panics with a special watchdog process. For logging to Sentry raven-go library is used.

Installation

go get github.com/muravjov/slog

Usage

dsn := "https://aaa:[email protected]/nnn"
slog.MustSetDSNAndHandler(dsn)

// log package support
slog.HookStandardLog()
// to capture panics
watcher.StartWatcher(dsn, "")

// you cannot survive that, see 
// https://github.com/golang/go/issues/20161
go func() {
	i := 0
	i = 1 / i
}()

After that code you receive an error into Sentry like that:

Post-mortem [/usr/sbin/cdn-mapi], pid=1: panic: runtime error: integer divide by zero

goroutine 30488 [running]:
slog.UncontrolledCrash.func1()
	/slog.go:36 +0x11
created by slog.UncontrolledCrash
	/slog.go:37 +0x35

Oneshot for simple logging

If you need to log errors to a local file log and to Sentry and you use package log for logging, e.g. in a simple utility, then take a look at this handy API:

slog.SetupLog(logPath, sentryDsn)

If you use go-logging:

slog.SetupGoLogging(logPath, sentryDsn, true)

If you use logrus:

slog.SetupLogrus(logPath, sentryDsn)

API documentation

https://godoc.org/github.com/muravjov/slog/sentry

https://godoc.org/github.com/muravjov/slog/watcher

sentry_prober

sentry_prober is utility to test/troubleshoot Sentry logging:

$ sentry_prober --help
Usage of ./sentry_prober:
      --message string     message to send (default "sentry-prober")
      --random             add random string to message
      --transport string   transport to use (not for --watcher): default|raven-go|slog|curl-print|curl-execute (default "default")
      --warning            warning (without stacktrace) vs error
      --watcher            send message via watcher

$ sentry_prober --transport curl-execute --warning https://user:[email protected]/ID
Sending "sentry-prober"...
curl -X POST -H 'X-Sentry-Auth: Sentry sentry_version=4, sentry_key=key, sentry_secret=key' -H 'User-Agent: slog/1.0' -H 'Content-Type: application/json' https://sentry.io/api/ID/store/ --data-binary \{\"message\":\"sentry-prober\"}
{"id":"uuid"}Event ID: uuid

About

No description, website, or topics provided.

Resources

Readme
License
Activity

Stars

1 star

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.