This commit is contained in:
Liang Ding 2014-12-14 23:05:54 +08:00
parent a8c5bd20a2
commit abfd4ad782
10 changed files with 34 additions and 15 deletions

View File

@ -233,7 +233,7 @@ func checkEnv() {
os.Exit(-1) os.Exit(-1)
} }
logger.Debug(string(buf)) logger.Trace(string(buf))
if "" == os.Getenv("GOPATH") { if "" == os.Getenv("GOPATH") {
logger.Error("Not found $GOPATH, please configure it before running Wide") logger.Error("Not found $GOPATH, please configure it before running Wide")

View File

@ -61,7 +61,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
session.EditorWS[sid] = &editorChan session.EditorWS[sid] = &editorChan
logger.Infof("Open a new [Editor] with session [%s], %d", sid, len(session.EditorWS)) logger.Tracef("Open a new [Editor] with session [%s], %d", sid, len(session.EditorWS))
args := map[string]interface{}{} args := map[string]interface{}{}
for { for {
@ -75,7 +75,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
offset := getCursorOffset(code, line, ch) offset := getCursorOffset(code, line, ch)
// logger.Infof("offset: %d", offset) // logger.Debugf("offset: %d", offset)
gocode := util.Go.GetExecutableInGOBIN("gocode") gocode := util.Go.GetExecutableInGOBIN("gocode")
argv := []string{"-f=json", "autocomplete", strconv.Itoa(offset)} argv := []string{"-f=json", "autocomplete", strconv.Itoa(offset)}

View File

@ -94,6 +94,26 @@ func (l *Logger) SetLevel(level string) {
l.level = getLevel(level) l.level = getLevel(level)
} }
// Trace prints trace level message.
func (l *Logger) Trace(v ...interface{}) {
if Debug < l.level {
return
}
l.logger.SetPrefix("T ")
l.logger.Output(2, fmt.Sprint(v...))
}
// Tracef prints trace level message with format.
func (l *Logger) Tracef(format string, v ...interface{}) {
if Debug < l.level {
return
}
l.logger.SetPrefix("T ")
l.logger.Output(2, fmt.Sprintf(format, v...))
}
// IsDebugEnabled determines whether the debug level is enabled. // IsDebugEnabled determines whether the debug level is enabled.
func (l *Logger) IsDebugEnabled() bool { func (l *Logger) IsDebugEnabled() bool {
return l.level <= Debug return l.level <= Debug

View File

@ -392,7 +392,7 @@ func stopwatch(handler func(w http.ResponseWriter, r *http.Request)) func(w http
start := time.Now() start := time.Now()
defer func() { defer func() {
logger.Debugf("[%s] [%s]", r.RequestURI, time.Since(start)) logger.Tracef("[%s] [%s]", r.RequestURI, time.Since(start))
}() }()
handler(w, r) handler(w, r)

View File

@ -109,7 +109,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
session.NotificationWS[sid] = &wsChan session.NotificationWS[sid] = &wsChan
logger.Debugf("Open a new [Notification] with session [%s], %d", sid, len(session.NotificationWS)) logger.Tracef("Open a new [Notification] with session [%s], %d", sid, len(session.NotificationWS))
// add user event handler // add user event handler
wSession.EventQueue.AddHandler(event.HandleFunc(event2Notification)) wSession.EventQueue.AddHandler(event.HandleFunc(event2Notification))

View File

@ -69,7 +69,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
session.OutputWS[sid] = &wsChan session.OutputWS[sid] = &wsChan
logger.Debugf("Open a new [Output] with session [%s], %d", sid, len(session.OutputWS)) logger.Tracef("Open a new [Output] with session [%s], %d", sid, len(session.OutputWS))
} }
// RunHandler handles request of executing a binary file. // RunHandler handles request of executing a binary file.
@ -362,7 +362,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
defer util.Recover() defer util.Recover()
defer cmd.Wait() defer cmd.Wait()
logger.Debugf("Session [%s] is building [id=%d, dir=%s]", sid, runningId, curDir) // logger.Debugf("Session [%s] is building [id=%d, dir=%s]", sid, runningId, curDir)
// read all // read all
buf, _ := ioutil.ReadAll(reader) buf, _ := ioutil.ReadAll(reader)
@ -454,7 +454,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
} }
if nil != session.OutputWS[sid] { if nil != session.OutputWS[sid] {
logger.Debugf("Session [%s] 's build [id=%d, dir=%s] has done", sid, runningId, curDir) // logger.Debugf("Session [%s] 's build [id=%d, dir=%s] has done", sid, runningId, curDir)
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
err := wsChannel.WriteJSON(&channelRet) err := wsChannel.WriteJSON(&channelRet)

View File

@ -177,7 +177,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
wSession = WideSessions.New(httpSession, sid) wSession = WideSessions.New(httpSession, sid)
logger.Debugf("Created a wide session [%s] for websocket reconnecting, user [%s]", sid, wSession.Username) logger.Tracef("Created a wide session [%s] for websocket reconnecting, user [%s]", sid, wSession.Username)
} }
conn, _ := websocket.Upgrade(w, r, nil, 1024, 1024) conn, _ := websocket.Upgrade(w, r, nil, 1024, 1024)
@ -191,14 +191,13 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
SessionWS[sid] = &wsChan SessionWS[sid] = &wsChan
logger.Debugf("Open a new [Session Channel] with session [%s], %d", sid, len(SessionWS)) logger.Tracef("Open a new [Session Channel] with session [%s], %d", sid, len(SessionWS))
input := map[string]interface{}{} input := map[string]interface{}{}
for { for {
if err := wsChan.ReadJSON(&input); err != nil { if err := wsChan.ReadJSON(&input); err != nil {
logger.Debugf("[Session Channel] of session [%s] disconnected, releases all resources with it, user [%s]", logger.Tracef("[Session Channel] of session [%s] disconnected, releases all resources with it, user [%s]", sid, wSession.Username)
sid, wSession.Username)
WideSessions.Remove(sid) WideSessions.Remove(sid)

View File

@ -70,7 +70,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
wideSessions := session.WideSessions.GetByUsername(username) wideSessions := session.WideSessions.GetByUsername(username)
logger.Debugf("User [%s] has [%d] sessions", username, len(wideSessions)) logger.Tracef("User [%s] has [%d] sessions", username, len(wideSessions))
t, err := template.ParseFiles("views/shell.html") t, err := template.ParseFiles("views/shell.html")

View File

@ -347,7 +347,7 @@
<div class="fn-right"> <div class="fn-right">
<img class="gravatar" <img class="gravatar"
onerror="this.src='/images/user-thumbnail.png'" onerror="this.src='/static/images/user-thumbnail.png'"
src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=17&d=http://symphony.b3log.org/images/user-thumbnail.png" src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=17&d=http://symphony.b3log.org/images/user-thumbnail.png"
title="{{.user.Name}}"/> title="{{.user.Name}}"/>
<span class="font-ico ico-share"></span> &nbsp; <span class="font-ico ico-share"></span> &nbsp;

View File

@ -91,7 +91,7 @@
<input data-value="{{.user.Password}}" value="{{.user.Password}}" name="password" type="password"/> <input data-value="{{.user.Password}}" value="{{.user.Password}}" name="password" type="password"/>
</label> </label>
<label class="fn-clear"> <label class="fn-clear">
<img onerror="this.src='/images/user-thumbnail.png'" <img onerror="this.src='/static/images/user-thumbnail.png'"
src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=48&d=http://symphony.b3log.org/images/user-thumbnail.png" src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=48&d=http://symphony.b3log.org/images/user-thumbnail.png"
title="{{.user.Name}}" class='gravatar'/> title="{{.user.Name}}" class='gravatar'/>
<a href="http://gravatar.com/" target="_blank">{{.i18n.change_avatar}} Gravatar.com</a> <a href="http://gravatar.com/" target="_blank">{{.i18n.change_avatar}} Gravatar.com</a>