2022-12-08 13:05:19 -03:00

39 lines
1.1 KiB
Go

// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License.AGPL.txt in the project root for license information.
package cmd
import (
"github.com/gitpod-io/gitpod/common-go/log"
"github.com/spf13/cobra"
)
var (
// ServiceName is the name we use for tracing/logging
ServiceName = "installation-telemetry"
// Version of this service - set during build
Version = ""
)
var jsonLog bool
var verbose bool
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: ServiceName,
Short: "This service sends telemetry information back to Gitpod",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.Init(ServiceName, Version, jsonLog, verbose)
},
}
func Execute() {
cobra.CheckErr(rootCmd.Execute())
}
func init() {
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
}