diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-01-03 16:57:43 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-01-03 16:57:43 +0100 |
commit | c344b1901fac755d44c889428f8972895d12fa66 (patch) | |
tree | f2b51ee616651e568e00773fd49f45a1eb0bf61c /commands | |
parent | 2ac9817eae7ddbb84c9d17c998d3ed004acc4b95 (diff) |
commands, helpers, vendor: Update to the latest jww logger
Updates #2701
Diffstat (limited to 'commands')
-rw-r--r-- | commands/hugo.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 4c3f0bdd5..9347a5081 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -17,6 +17,7 @@ package commands import ( "fmt" + "io/ioutil" "net/http" "os" "path/filepath" @@ -332,16 +333,27 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error { viper.Set("cacheDir", helpers.GetTempDir("hugo_cache", hugofs.Source())) } + logFile := ioutil.Discard + if verboseLog || logging || (viper.IsSet("logFile") && viper.GetString("logFile") != "") { + + var err error if viper.IsSet("logFile") && viper.GetString("logFile") != "" { - jww.SetLogFile(viper.GetString("logFile")) + path := viper.GetString("logFile") + logFile, err = os.OpenFile(path, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666) + if err != nil { + return newSystemError("Failed to open log file:", path, err) + } } else { - jww.UseTempLogFile("hugo") + logFile, err = ioutil.TempFile(os.TempDir(), "hugo") + if err != nil { + return newSystemError(err) + } } - } else { - jww.DiscardLogging() } + jww.SetLogOutput(logFile) + if quiet { jww.SetStdoutThreshold(jww.LevelError) } else if viper.GetBool("verbose") { |