Ejemplo n.º 1
0
func main() {
	cfg := config.NewConfig()

	http.Handle("/", index(cfg))
	http.Handle("/assets/", assets(cfg))

	logs.Debug.Print("[config] " + cfg.String())
	logs.Info.Printf("[service] listening on port %v", cfg.Port)
	logs.Fatal.Print(http.ListenAndServe(":"+fmt.Sprint(cfg.Port), nil))
}
Ejemplo n.º 2
0
// CommonParams returns html common parameters
func CommonParams(w http.ResponseWriter, r *http.Request) *models.PageParameters {
	session := util.GetSessionInfo(r)
	cfg := config.NewConfig()

	return &models.PageParameters{
		User: &models.UserParameters{
			ID: session.UserID,
		},
		Mode: cfg.Mode,
	}
}
Ejemplo n.º 3
0
func init() {
	level = logLevel(math.Min(float64(trace), math.Max(float64(fatal), float64(config.NewConfig().LogLevel))))

	handle := ioutil.Discard
	if level >= fatal {
		handle = os.Stderr
	}
	Fatal = log.New(handle, "FATAL: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= err {
		handle = os.Stderr
	}
	Error = log.New(handle, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= warn {
		handle = os.Stdout
	}
	Warn = log.New(handle, "WARNING: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= info {
		handle = os.Stdout
	}
	Info = log.New(handle, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= debug {
		handle = os.Stdout
	}
	Debug = log.New(handle, "DEBUG: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= trace {
		handle = os.Stdout
	}
	Trace = log.New(handle, "TRACE: ", log.Ldate|log.Ltime|log.Lshortfile)
}
Ejemplo n.º 4
0
func init() {
	cfg = config.NewConfig()
}