Ensure error reporting works in Google Cloud

This commit is contained in:
Tobie Morgan Hitchcock 2020-11-27 12:56:12 +00:00
parent 8770379a73
commit f6b75e2de2

View file

@ -32,6 +32,8 @@ import (
"cloud.google.com/go/logging" "cloud.google.com/go/logging"
) )
var proj = os.Getenv("PROJECT")
type StackdriverLogger struct { type StackdriverLogger struct {
name string name string
client *logging.Client client *logging.Client
@ -45,12 +47,10 @@ func NewStackDriver() *StackdriverLogger {
ctx := context.Background() ctx := context.Background()
proj := os.Getenv("PROJECT")
hook := new(StackdriverLogger) hook := new(StackdriverLogger)
conf := errorreporting.Config{ conf := errorreporting.Config{
ServiceName: name, ServiceName: "surreal",
ServiceVersion: build.GetInfo().Ver, ServiceVersion: build.GetInfo().Ver,
} }
@ -91,7 +91,7 @@ func NewStackDriver() *StackdriverLogger {
log.Fatalf("Failed to connect to Stackdriver: %v", err) log.Fatalf("Failed to connect to Stackdriver: %v", err)
} }
hook.logger = hook.client.Logger(name) hook.logger = hook.client.Logger("surreal")
return hook return hook