-
Notifications
You must be signed in to change notification settings - Fork 1
/
raygun.go
47 lines (37 loc) · 945 Bytes
/
raygun.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package raygun
import (
"reflect"
)
const RaygunEndpoint = "https://api.raygun.io"
const ClientName = "Raygun Go"
const ClientVersion = "0.1"
const ClientURL = "http://github.com/tomersimis/raygun"
var PackageName = reflect.TypeOf(NoopCollector{}).PkgPath()
var GlobalCollector Collector = &NoopCollector{}
func SetGlobalCollector(collector Collector) {
GlobalCollector = collector
}
func CaptureError(err error, opts ...CaptureOption) {
GlobalCollector.CaptureError(err, opts...)
}
func CapturePanic() {
if rec := recover(); rec != nil {
if err, ok := rec.(error); ok {
GlobalCollector.CaptureError(err)
} else {
GlobalCollector.CaptureMessage(rec.(string))
}
}
}
func CaptureMessage(msg string, opts ...CaptureOption) {
GlobalCollector.CaptureMessage(msg, opts...)
}
func Capture(ray Ray) {
GlobalCollector.Capture(ray)
}
func Wait() {
switch c := GlobalCollector.(type) {
case *RaygunCollector:
c.Wait()
}
}