-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (38 loc) · 950 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/vshn/appcat-apiserver/cmd"
)
func init() {
rootCmd.AddCommand(cmd.APIServerCMD)
}
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
var (
logLevel int
logFormat string
rootCmd = &cobra.Command{
Short: "AppCat",
Long: "AppCat controllers, api servers, grpc servers and probers",
PersistentPreRunE: setupLogging,
}
)
func init() {
rootCmd.PersistentFlags().IntVarP(&logLevel, "log-level", "v", 0, "Number of the log level verbosity.")
rootCmd.PersistentFlags().StringVar(&logFormat, "log-format", "console", "Sets the log format (values: [json, console]).")
viper.AutomaticEnv()
}
func setupLogging(cmd *cobra.Command, _ []string) error {
err := SetupLogging(cmd, logLevel, logFormat)
if err != nil {
return err
}
return LogMetadata(cmd)
}