1
0
Fork 0

Remove environment setting and debugging

This commit is contained in:
Gregory Eremin 2014-09-09 12:03:42 +04:00
parent 0c33d2fd20
commit 56c1ec2300
3 changed files with 2 additions and 18 deletions

View File

@ -7,14 +7,12 @@ import (
var (
Config struct {
Storage string
Env string
Port int
}
)
func SetupConfig() {
flag.StringVar(&Config.Storage, "storage", "-", "Kyoto Cabinet storage path (e.g. burlesque.kch#dfunit=8#msiz=512M)")
flag.StringVar(&Config.Env, "environment", "production", "Process environment: production or development")
flag.IntVar(&Config.Port, "port", 4401, "Server HTTP port")
flag.Parse()
}

View File

@ -13,7 +13,7 @@ var (
func SetupLogging() {
logger = log.New(os.Stdout, "", log.Ldate|log.Lmicroseconds)
Log("Burlesque v%s started in %s environment", Version, Config.Env)
Log("Burlesque v%s started", Version)
Log("GOMAXPROCS is set to %d", runtime.GOMAXPROCS(-1))
Log("Storage path: %s", Config.Storage)
Log("Server is running at http://127.0.0.1:%d", Config.Port)
@ -23,18 +23,7 @@ func Log(format string, args ...interface{}) {
logger.Printf("[INFO] "+format, args...)
}
func Debug(format string, args ...interface{}) {
if Config.Env == "development" {
logger.Printf("[DEBUG] "+format, args...)
}
}
func Error(err error, format string, args ...interface{}) {
logger.Printf("[ERROR] "+format, args...)
if Config.Env == "development" {
panic(err)
} else {
logger.Printf(" %s", err.Error())
}
logger.Printf(" %s", err.Error())
}

View File

@ -77,10 +77,8 @@ func PublishHandler(w http.ResponseWriter, r *http.Request) {
ok := RegisterPublication(qname, msg)
if ok {
Debug("Published message of %d bytes to queue %s", len(msg), qname)
w.Write([]byte("OK"))
} else {
Debug("Failed to publish message of %d bytes to queue %s", len(msg), qname)
http.Error(w, "FAIL", 500)
}
}
@ -115,7 +113,6 @@ func SubscriptionHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Queue", res.Queue)
w.Write(res.Message)
Debug("Recieved message of %d bytes from queue %s", len(res.Message), res.Queue)
finished <- true
}