diff options
-rw-r--r-- | commands/hugo.go | 8 | ||||
-rw-r--r-- | utils/utils.go | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 95e1c5864..ad9aa316c 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -366,7 +366,7 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) { cacheDir = cacheDir + helpers.FilePathSeparator } isDir, err := helpers.DirExists(cacheDir, cfg.Fs.Source) - utils.CheckErr(err) + utils.CheckErr(cfg.Logger, err) if !isDir { mkdir(cacheDir) } @@ -481,7 +481,7 @@ func (c *commandeer) watchConfig() { v.OnConfigChange(func(e fsnotify.Event) { c.Logger.FEEDBACK.Println("Config file changed:", e.Name) // Force a full rebuild - utils.CheckErr(c.recreateAndBuildSites(true)) + utils.CheckErr(c.Logger, c.recreateAndBuildSites(true)) if !c.Cfg.GetBool("disableLiveReload") { // Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized livereload.ForceRefresh() @@ -504,7 +504,7 @@ func (c *commandeer) build(watches ...bool) error { if buildWatch { c.Logger.FEEDBACK.Println("Watching for changes in", c.PathSpec().AbsPathify(c.Cfg.GetString("contentDir"))) c.Logger.FEEDBACK.Println("Press Ctrl+C to stop") - utils.CheckErr(c.newWatcher(0)) + utils.CheckErr(c.Logger, c.newWatcher(0)) } return nil @@ -841,7 +841,7 @@ func (c *commandeer) newWatcher(port int) error { c.Logger.FEEDBACK.Printf("Syncing all static files\n") err := c.copyStatic() if err != nil { - utils.StopOnErr(err, fmt.Sprintf("Error copying static files to %s", publishDir)) + utils.StopOnErr(c.Logger, err, fmt.Sprintf("Error copying static files to %s", publishDir)) } } else { staticSourceFs := c.getStaticSourceFs() diff --git a/utils/utils.go b/utils/utils.go index a3329c4a9..87357a26e 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -21,22 +21,22 @@ import ( // CheckErr logs the messages given and then the error. // TODO(bep) Remove this package. -func CheckErr(err error, s ...string) { +func CheckErr(logger *jww.Notepad, err error, s ...string) { if err == nil { return } if len(s) == 0 { - jww.CRITICAL.Println(err) + logger.CRITICAL.Println(err) return } for _, message := range s { - jww.ERROR.Println(message) + logger.ERROR.Println(message) } - jww.ERROR.Println(err) + logger.ERROR.Println(err) } // StopOnErr exits on any error after logging it. -func StopOnErr(err error, s ...string) { +func StopOnErr(logger *jww.Notepad, err error, s ...string) { if err == nil { return } @@ -48,12 +48,12 @@ func StopOnErr(err error, s ...string) { // Printing an empty string results in a error with // no message, no bueno. if newMessage != "" { - jww.CRITICAL.Println(newMessage) + logger.CRITICAL.Println(newMessage) } } for _, message := range s { if message != "" { - jww.CRITICAL.Println(message) + logger.CRITICAL.Println(message) } } } |