in cobra/cmd/root.go [50:86]
func initConfig() {
app := aid.GetAppInfo()
viper.AddConfigPath(app.ConfigurationsDir) // global directory
viper.SetConfigName(app.ConfigurationsName)
viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
fmt.Println("using config file:", viper.ConfigFileUsed())
}
verbosity, err := rootCmd.Flags().GetString("verbosity")
if err != nil {
fmt.Printf("unable to read flag verbosity\n%v", err)
}
log, err := rootCmd.Flags().GetBool("log")
if err != nil {
fmt.Printf("unable to read flag err\n%v", err)
}
logFilePath, err := rootCmd.Flags().GetString("log-file-path")
if err != nil {
fmt.Printf("unable to read flag log-file-path\n%v", err)
}
if log && logFilePath != "" {
if err := aid.SetupLoggingLevel(verbosity); err == nil {
fmt.Printf("logging level: %s\n", verbosity)
}
if err := aid.SetupLoggingOutput(logFilePath); err == nil {
fmt.Printf("logging path: %s\n", logFilePath)
}
}
}