cuelang.org/go@v0.10.1/internal/golangorgx/telemetry/upload/upload.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package upload 6 7 import ( 8 "io" 9 "log" 10 11 "cuelang.org/go/internal/golangorgx/telemetry/internal/upload" 12 ) 13 14 // Run generates and uploads reports, as allowed by the mode file. 15 // A nil Control is legal. 16 func Run(c *Control) { 17 if c != nil && c.Logging != nil { 18 upload.SetLogOutput(c.Logging) 19 } 20 // ignore error: failed logging should not block uploads 21 upload.LogIfDebug("") 22 23 defer func() { 24 if err := recover(); err != nil { 25 log.Printf("upload recover: %v", err) 26 } 27 }() 28 upload.NewUploader(nil).Run() 29 } 30 31 // A Control allows the user to override various default 32 // reporting and uploading choices. 33 // Future versions may also allow the user to set the upload URL. 34 type Control struct { 35 // Logging provides a io.Writer for error messages during uploading 36 // nil is legal and no log messages get generated 37 Logging io.Writer 38 }