New func GetConfigFilePath() which returns the path where Viper actually found the logfile

This commit is contained in:
Fabian Knorr 2018-02-05 21:49:41 +01:00
parent aafc9e6bc7
commit 48307d640f
1 changed files with 9 additions and 0 deletions

View File

@ -1734,6 +1734,15 @@ func (v *Viper) getConfigFile() (string, error) {
return v.getConfigFile()
}
func GetConfigFilePath() (string, error) {
// Returns the path where Viper actually found the logfile it uses.
//
// Useful when you want to write the configPath to logfiles, stdout, etc.
// Comes in handy during debugging or when running in production environments.
cf, err := v.getConfigFile()
return cf, err
}
func (v *Viper) searchInPath(in string) (filename string) {
jww.DEBUG.Println("Searching for config in ", in)
for _, ext := range SupportedExts {