Remove environment setting and debugging
This commit is contained in:
parent
0c33d2fd20
commit
56c1ec2300
@ -7,14 +7,12 @@ import (
|
|||||||
var (
|
var (
|
||||||
Config struct {
|
Config struct {
|
||||||
Storage string
|
Storage string
|
||||||
Env string
|
|
||||||
Port int
|
Port int
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupConfig() {
|
func SetupConfig() {
|
||||||
flag.StringVar(&Config.Storage, "storage", "-", "Kyoto Cabinet storage path (e.g. burlesque.kch#dfunit=8#msiz=512M)")
|
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.IntVar(&Config.Port, "port", 4401, "Server HTTP port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
13
logging.go
13
logging.go
@ -13,7 +13,7 @@ var (
|
|||||||
func SetupLogging() {
|
func SetupLogging() {
|
||||||
logger = log.New(os.Stdout, "", log.Ldate|log.Lmicroseconds)
|
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("GOMAXPROCS is set to %d", runtime.GOMAXPROCS(-1))
|
||||||
Log("Storage path: %s", Config.Storage)
|
Log("Storage path: %s", Config.Storage)
|
||||||
Log("Server is running at http://127.0.0.1:%d", Config.Port)
|
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...)
|
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{}) {
|
func Error(err error, format string, args ...interface{}) {
|
||||||
logger.Printf("[ERROR] "+format, args...)
|
logger.Printf("[ERROR] "+format, args...)
|
||||||
|
|
||||||
if Config.Env == "development" {
|
|
||||||
panic(err)
|
|
||||||
} else {
|
|
||||||
logger.Printf(" %s", err.Error())
|
logger.Printf(" %s", err.Error())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -77,10 +77,8 @@ func PublishHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
ok := RegisterPublication(qname, msg)
|
ok := RegisterPublication(qname, msg)
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
Debug("Published message of %d bytes to queue %s", len(msg), qname)
|
|
||||||
w.Write([]byte("OK"))
|
w.Write([]byte("OK"))
|
||||||
} else {
|
} else {
|
||||||
Debug("Failed to publish message of %d bytes to queue %s", len(msg), qname)
|
|
||||||
http.Error(w, "FAIL", 500)
|
http.Error(w, "FAIL", 500)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +113,6 @@ func SubscriptionHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Queue", res.Queue)
|
w.Header().Set("Queue", res.Queue)
|
||||||
w.Write(res.Message)
|
w.Write(res.Message)
|
||||||
|
|
||||||
Debug("Recieved message of %d bytes from queue %s", len(res.Message), res.Queue)
|
|
||||||
finished <- true
|
finished <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user