gddo-server: fix use of cloud logging library
A breaking change was made to the cloud logging library. This updates gddo to compile after the change.
Change-Id: I8f462f2e3447671c86f44b8a15a31fa2da7f117d
Reviewed-on: https://go-review.googlesource.com/30694
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/gddo-server/logging.go b/gddo-server/logging.go
index 20490b2..f32fe3b 100644
--- a/gddo-server/logging.go
+++ b/gddo-server/logging.go
@@ -19,12 +19,12 @@
// newGCELogger returns a handler that wraps h but logs each request
// using Google Cloud Logging service.
-func newGCELogger(cli *logging.Client) *GCELogger {
+func newGCELogger(cli *logging.Logger) *GCELogger {
return &GCELogger{cli}
}
type GCELogger struct {
- cli *logging.Client
+ cli *logging.Logger
}
// LogEvent creates an entry in Cloud Logging to record user's behavior. We should only
@@ -66,7 +66,6 @@
// Log queues the entry to its internal buffer, or discarding the entry
// if the buffer was full.
g.cli.Log(logging.Entry{
- Time: time.Now().UTC(),
Payload: payload,
})
}
diff --git a/gddo-server/main.go b/gddo-server/main.go
index 869ca6c..caf3452 100644
--- a/gddo-server/main.go
+++ b/gddo-server/main.go
@@ -1012,14 +1012,18 @@
}
if gceLogName != "" {
ctx := context.Background()
- logc, err := logging.NewClient(ctx, projID, gceLogName)
+
+ logc, err := logging.NewClient(ctx, projID)
if err != nil {
log.Fatalf("Failed to create cloud logging client: %v", err)
}
- if err := logc.Ping(); err != nil {
+ logger := logc.Logger(gceLogName)
+
+ if err := logc.Ping(nil); err != nil {
log.Fatalf("Failed to ping Google Cloud Logging: %v", err)
}
- gceLogger = newGCELogger(logc)
+
+ gceLogger = newGCELogger(logger)
}
http.Handle("/", root)