mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
utils: Use local logger
This commit is contained in:
parent
75d855c086
commit
41857d036d
2 changed files with 11 additions and 11 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue