commands, helpers, vendor: Update to the latest jww logger
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 3 Jan 2017 15:57:43 +0000 (16:57 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 3 Jan 2017 15:57:43 +0000 (16:57 +0100)
Updates #2701

commands/hugo.go
helpers/general.go
vendor/vendor.json

index 4c3f0bdd533ac1059ea6d2ff7e9c0e8f3985e3be..9347a50813fa85893adbd15a6696250c3e87783d 100644 (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") {
index 740c05f5c992344c9426a81b529badbad14040b6..c545b286d45b64bd28891152e4cf60af379e13ea 100644 (file)
@@ -252,7 +252,7 @@ func NewDistinctErrorLogger() *DistinctLogger {
 // NewDistinctFeedbackLogger creates a new DistinctLogger that can be used
 // to give feedback to the user while not spamming with duplicates.
 func NewDistinctFeedbackLogger() *DistinctLogger {
-       return &DistinctLogger{m: make(map[string]bool), logger: &jww.FEEDBACK}
+       return &DistinctLogger{m: make(map[string]bool), logger: jww.FEEDBACK}
 }
 
 var (
index 875b5c59818a1bf614c3a019bf3d8804cdf38b73..ef8db0857da65b92bd39e2cb2bb1a1cb6d1db1bb 100644 (file)
                        "revisionTime": "2016-11-30T04:45:28Z"
                },
                {
-                       "checksumSHA1": "dkruahfhuLXXuyeCuRpsWlcRK+8=",
+                       "checksumSHA1": "7NGKyJZL8VItCxYkEJxNh8l9O18=",
                        "path": "github.com/spf13/jwalterweatherman",
-                       "revision": "33c24e77fb80341fe7130ee7c594256ff08ccc46",
-                       "revisionTime": "2016-03-01T12:00:06Z"
+                       "revision": "14fe3f27973f14e5d1bb8bb16f6153cc67b30652",
+                       "revisionTime": "2017-01-03T11:13:15Z"
                },
                {
                        "checksumSHA1": "zLJY+lsX1e5OO6gRxQd5RfKgdQY=",