summaryrefslogtreecommitdiffstats
path: root/hugolib/config.go
diff options
context:
space:
mode:
authorspf13 <steve.francia@gmail.com>2014-03-31 13:23:34 -0400
committerspf13 <steve.francia@gmail.com>2014-03-31 13:23:34 -0400
commite50b9d8ac1c69aa16cf45b1e4ff95b22d535adb7 (patch)
tree8c16489a5cf2631649805d547256d4427d9486d8 /hugolib/config.go
parent2fa3761ec993657330d5b9ddbaaab1f58797fb61 (diff)
Adding support for logging & verbose logging. Consolidation of error handling. Integration of jWalterWeatherman library. Fixed #137
Diffstat (limited to 'hugolib/config.go')
-rw-r--r--hugolib/config.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/hugolib/config.go b/hugolib/config.go
index a52b0737c..c3f753cd4 100644
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -16,21 +16,23 @@ package hugolib
import (
"encoding/json"
"fmt"
- "github.com/BurntSushi/toml"
- "github.com/spf13/hugo/helpers"
"io/ioutil"
- "launchpad.net/goyaml"
"os"
"path"
"path/filepath"
"strings"
+
+ "github.com/BurntSushi/toml"
+ "github.com/spf13/hugo/helpers"
+ jww "github.com/spf13/jwalterweatherman"
+ "launchpad.net/goyaml"
)
// config file items
type Config struct {
ContentDir, PublishDir, BaseUrl, StaticDir string
Path, CacheDir, LayoutDir, DefaultLayout string
- ConfigFile string
+ ConfigFile, LogFile string
Title string
Indexes map[string]string // singular, plural
ProcessFilters map[string][]string
@@ -50,8 +52,8 @@ func SetupConfig(cfgfile *string, path *string) *Config {
c.ConfigFile = cfg
if err != nil {
- fmt.Printf("%v", err)
- fmt.Println(" using defaults instead")
+ jww.ERROR.Printf("%v", err)
+ jww.FEEDBACK.Println("using defaults instead")
}
// set defaults
@@ -92,19 +94,19 @@ func (c *Config) readInConfig() {
switch path.Ext(c.ConfigFile) {
case ".yaml":
if err := goyaml.Unmarshal(file, &c); err != nil {
- fmt.Printf("Error parsing config: %s", err)
+ jww.ERROR.Printf("Error parsing config: %s", err)
os.Exit(1)
}
case ".json":
if err := json.Unmarshal(file, &c); err != nil {
- fmt.Printf("Error parsing config: %s", err)
+ jww.ERROR.Printf("Error parsing config: %s", err)
os.Exit(1)
}
case ".toml":
if _, err := toml.Decode(string(file), &c); err != nil {
- fmt.Printf("Error parsing config: %s", err)
+ jww.ERROR.Printf("Error parsing config: %s", err)
os.Exit(1)
}
}
@@ -115,13 +117,13 @@ func (c *Config) setPath(p string) {
if p == "" {
path, err := findPath()
if err != nil {
- fmt.Printf("Error finding path: %s", err)
+ jww.ERROR.Printf("Error finding path: %s", err)
}
c.Path = path
} else {
path, err := filepath.Abs(p)
if err != nil {
- fmt.Printf("Error finding path: %s", err)
+ jww.ERROR.Printf("Error finding path: %s", err)
}
c.Path = path
}