From 3189c5d145cba478f38b31e7b70518cbe3d2fbe8 Mon Sep 17 00:00:00 2001 From: olemorud Date: Thu, 8 Dec 2022 00:35:24 +0100 Subject: [PATCH] Rewrite logging client instantiation --- src/function.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/function.go b/src/function.go index 6613f55..a0633ee 100644 --- a/src/function.go +++ b/src/function.go @@ -42,20 +42,13 @@ func contains(haystack []string, needle string) bool { // Coffee() replies to mattermost webhooks with the correct token value func Coffee(writer http.ResponseWriter, request *http.Request) { project_id := os.Getenv("PROJECT_ID") - - if project_id == "" { - log.Fatal("Environment variable PROJECT_ID is empty") - } - - // Create cloud logging client ctx := context.Background() client, err := logging.NewClient(ctx, project_id) - - logger := client.Logger("Coffee-log") var stdlog *log.Logger if err != nil { defer client.Close() + logger := client.Logger("Coffee-log") stdlog = logger.StandardLogger(logging.Debug) } else { log.Printf("Failed to create logging client: %v", err)