logging
This commit is contained in:
parent
ec0ca1e118
commit
a0fefc5db8
|
@ -39,13 +39,11 @@ var logger = log.NewLogger(os.Stdout)
|
||||||
|
|
||||||
// IndexHandler handles request of Playground index.
|
// IndexHandler handles request of Playground index.
|
||||||
func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
username := "playground"
|
|
||||||
|
|
||||||
// create a HTTP session
|
// create a HTTP session
|
||||||
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
||||||
if httpSession.IsNew {
|
if httpSession.IsNew {
|
||||||
httpSession.Values["id"] = strconv.Itoa(rand.Int())
|
httpSession.Values["id"] = strconv.Itoa(rand.Int())
|
||||||
httpSession.Values["username"] = username
|
httpSession.Values["username"] = "playground"
|
||||||
}
|
}
|
||||||
|
|
||||||
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
|
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
|
||||||
|
@ -54,6 +52,8 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
httpSession.Save(r, w)
|
httpSession.Save(r, w)
|
||||||
|
|
||||||
|
username := httpSession.Values["username"].(string)
|
||||||
|
|
||||||
// create a wide session
|
// create a wide session
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
sid := strconv.Itoa(rand.Int())
|
sid := strconv.Itoa(rand.Int())
|
||||||
|
@ -87,7 +87,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
wideSessions := session.WideSessions.GetByUsername(username)
|
wideSessions := session.WideSessions.GetByUsername(username)
|
||||||
|
|
||||||
logger.Tracef("User [%s] has [%d] sessions", username, len(wideSessions))
|
logger.Debugf("User [%s] has [%d] sessions", username, len(wideSessions))
|
||||||
|
|
||||||
t, err := template.ParseFiles("views/playground/index.html")
|
t, err := template.ParseFiles("views/playground/index.html")
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ func (sessions *wSessions) Remove(sid string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Tracef("Removed a session [%s] of user [%s], it has [%d] sessions currently", sid, s.Username, cnt)
|
logger.Debugf("Removed a session [%s] of user [%s], it has [%d] sessions currently", sid, s.Username, cnt)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue