Skip to content

Commit

Permalink
Updating logs
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Dec 20, 2022
1 parent 6182e91 commit 231d3d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ func initConfig(baseSearchPath *pathlib.Path, viperObj *viper.Viper) {

currentDir := baseSearchPath

for len(currentDir.Parts()) > 1 {
for {
viperObj.AddConfigPath(currentDir.String())
if len(currentDir.Parts()) <= 1 {
break
}
currentDir = currentDir.Parent()
}

Expand All @@ -144,9 +147,8 @@ func initConfig(baseSearchPath *pathlib.Path, viperObj *viper.Viper) {
}

// Note we purposely ignore the error. Don't care if we can't find a config file.
if err := viperObj.ReadInConfig(); err == nil {
fmt.Fprintf(os.Stderr, "Using config file: %s\n", viperObj.ConfigFileUsed())
}
viperObj.ReadInConfig()
viperObj.Set("config", viperObj.ConfigFileUsed())
}

const regexMetadataChars = "\\.+*?()|[]{}^$"
Expand Down
7 changes: 7 additions & 0 deletions cmd/showconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func NewShowConfigCmd() *cobra.Command {
This initializes viper and prints out the merged configuration between
config files, environment variables, and CLI flags.`,
RunE: func(cmd *cobra.Command, args []string) error {

config := &config.Config{}
if err := viper.UnmarshalExact(config); err != nil {
return errors.Wrapf(err, "failed to unmarshal config")
Expand All @@ -26,6 +27,12 @@ func NewShowConfigCmd() *cobra.Command {
if err != nil {
return errors.Wrapf(err, "Failed to marshal yaml")
}
log, err := getLogger(config.LogLevel)
if err != nil {
panic(err)
}
log.Info().Msgf("Using config: %s", config.Config)

fmt.Printf("%s", string(out))
return nil
},
Expand Down

0 comments on commit 231d3d6

Please sign in to comment.