summaryrefslogtreecommitdiffstats
path: root/utils/config.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-04 11:59:10 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-04 11:59:10 -0700
commit58d0d9afd286afd715e9f04825e1305045d404e2 (patch)
tree10615aa68c68106684503fb18ae4e4ef8998bc22 /utils/config.go
parent05d95d80a896d14474c7f7384d67b9edd524b922 (diff)
downloadchat-58d0d9afd286afd715e9f04825e1305045d404e2.tar.gz
chat-58d0d9afd286afd715e9f04825e1305045d404e2.tar.bz2
chat-58d0d9afd286afd715e9f04825e1305045d404e2.zip
Adding cmd line options
Diffstat (limited to 'utils/config.go')
-rw-r--r--utils/config.go27
1 files changed, 11 insertions, 16 deletions
diff --git a/utils/config.go b/utils/config.go
index f49840453..c67e17e79 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -6,7 +6,6 @@ package utils
import (
l4g "code.google.com/p/log4go"
"encoding/json"
- "net/mail"
"os"
"path/filepath"
)
@@ -149,7 +148,7 @@ func (o *Config) ToJson() string {
var Cfg *Config = &Config{}
var SanitizeOptions map[string]bool = map[string]bool{}
-func findConfigFile(fileName string) string {
+func FindConfigFile(fileName string) string {
if _, err := os.Stat("/tmp/" + fileName); err == nil {
fileName, _ = filepath.Abs("/tmp/" + fileName)
} else if _, err := os.Stat("./config/" + fileName); err == nil {
@@ -176,6 +175,14 @@ func FindDir(dir string) string {
return fileName + "/"
}
+func ConfigureCmdLineLog() {
+ ls := LogSettings{}
+ ls.ConsoleEnable = true
+ ls.ConsoleLevel = "ERROR"
+ ls.FileEnable = false
+ configureLog(ls)
+}
+
func configureLog(s LogSettings) {
l4g.Close()
@@ -220,8 +227,7 @@ func configureLog(s LogSettings) {
// then ../config/fileName and last it will look at fileName
func LoadConfig(fileName string) {
- fileName = findConfigFile(fileName)
- l4g.Info("Loading config file at " + fileName)
+ fileName = FindConfigFile(fileName)
file, err := os.Open(fileName)
if err != nil {
@@ -232,24 +238,13 @@ func LoadConfig(fileName string) {
config := Config{}
err = decoder.Decode(&config)
if err != nil {
- panic("Error decoding configuration " + err.Error())
- }
-
- // Check for a valid email for feedback, if not then do feedback@domain
- if _, err := mail.ParseAddress(config.EmailSettings.FeedbackEmail); err != nil {
- l4g.Error("Misconfigured feedback email setting: %s", config.EmailSettings.FeedbackEmail)
- config.EmailSettings.FeedbackEmail = "feedback@localhost"
+ panic("Error decoding config file=" + fileName + ", err=" + err.Error())
}
configureLog(config.LogSettings)
Cfg = &config
SanitizeOptions = getSanitizeOptions()
-
- // Validates our mail settings
- if err := CheckMailSettings(); err != nil {
- l4g.Error("Email settings are not valid err=%v", err)
- }
}
func getSanitizeOptions() map[string]bool {