cuelang.org/go@v0.10.1/internal/golangorgx/telemetry/mode.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 telemetry
     6  
     7  import (
     8  	it "cuelang.org/go/internal/golangorgx/telemetry/internal/telemetry"
     9  )
    10  
    11  // Mode returns the current telemetry mode.
    12  //
    13  // The telemetry mode is a global value that controls both the local collection
    14  // and uploading of telemetry data. Possible mode values are:
    15  //   - "on":    both collection and uploading is enabled
    16  //   - "local": collection is enabled, but uploading is disabled
    17  //   - "off":   both collection and uploading are disabled
    18  //
    19  // When mode is "on", or "local", telemetry data is written to the local file
    20  // system and may be inspected with the [gotelemetry] command.
    21  //
    22  // If an error occurs while reading the telemetry mode from the file system,
    23  // Mode returns the default value "local".
    24  //
    25  // [gotelemetry]: https://pkg.go.dev/cuelang.org/go/internal/golangorgx/telemetry/cmd/gotelemetry
    26  func Mode() string {
    27  	mode, _ := it.Mode()
    28  	return mode
    29  }
    30  
    31  // SetMode sets the global telemetry mode to the given value.
    32  //
    33  // See the documentation of [Mode] for a description of the supported mode
    34  // values.
    35  //
    36  // An error is returned if the provided mode value is invalid, or if an error
    37  // occurs while persisting the mode value to the file system.
    38  func SetMode(mode string) error {
    39  	return it.SetMode(mode)
    40  }