Rewrite logging client instantiation
This commit is contained in:
@@ -42,20 +42,13 @@ func contains(haystack []string, needle string) bool {
|
|||||||
// Coffee() replies to mattermost webhooks with the correct token value
|
// Coffee() replies to mattermost webhooks with the correct token value
|
||||||
func Coffee(writer http.ResponseWriter, request *http.Request) {
|
func Coffee(writer http.ResponseWriter, request *http.Request) {
|
||||||
project_id := os.Getenv("PROJECT_ID")
|
project_id := os.Getenv("PROJECT_ID")
|
||||||
|
|
||||||
if project_id == "" {
|
|
||||||
log.Fatal("Environment variable PROJECT_ID is empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create cloud logging client
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
client, err := logging.NewClient(ctx, project_id)
|
client, err := logging.NewClient(ctx, project_id)
|
||||||
|
|
||||||
logger := client.Logger("Coffee-log")
|
|
||||||
var stdlog *log.Logger
|
var stdlog *log.Logger
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
logger := client.Logger("Coffee-log")
|
||||||
stdlog = logger.StandardLogger(logging.Debug)
|
stdlog = logger.StandardLogger(logging.Debug)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Failed to create logging client: %v", err)
|
log.Printf("Failed to create logging client: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user