commands, helpers, vendor: Update to the latest jww logger

Updates #2701
This commit is contained in:
Bjørn Erik Pedersen
2017-01-03 16:57:43 +01:00
parent 2ac9817eae
commit c344b1901f
3 changed files with 20 additions and 8 deletions

View File

@@ -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") {