Exemple #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))
}
Exemple #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,
	}
}
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)
}
Exemple #4
0
func init() {
	cfg = config.NewConfig()
}