diff --git a/conf/wide.go b/conf/wide.go index 7ba96b9..f31b04b 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -233,7 +233,7 @@ func checkEnv() { os.Exit(-1) } - logger.Debug(string(buf)) + logger.Trace(string(buf)) if "" == os.Getenv("GOPATH") { logger.Error("Not found $GOPATH, please configure it before running Wide") diff --git a/editor/editors.go b/editor/editors.go index b485f0a..4a4c441 100644 --- a/editor/editors.go +++ b/editor/editors.go @@ -61,7 +61,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) { 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{}{} for { @@ -75,7 +75,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) { offset := getCursorOffset(code, line, ch) - // logger.Infof("offset: %d", offset) + // logger.Debugf("offset: %d", offset) gocode := util.Go.GetExecutableInGOBIN("gocode") argv := []string{"-f=json", "autocomplete", strconv.Itoa(offset)} diff --git a/log/logs.go b/log/logs.go index ea90c40..d1f7e75 100755 --- a/log/logs.go +++ b/log/logs.go @@ -94,6 +94,26 @@ func (l *Logger) SetLevel(level string) { 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. func (l *Logger) IsDebugEnabled() bool { return l.level <= Debug diff --git a/main.go b/main.go index d5d40f3..77b7018 100644 --- a/main.go +++ b/main.go @@ -392,7 +392,7 @@ func stopwatch(handler func(w http.ResponseWriter, r *http.Request)) func(w http start := time.Now() defer func() { - logger.Debugf("[%s] [%s]", r.RequestURI, time.Since(start)) + logger.Tracef("[%s] [%s]", r.RequestURI, time.Since(start)) }() handler(w, r) diff --git a/notification/notifications.go b/notification/notifications.go index 68b9772..91fed48 100644 --- a/notification/notifications.go +++ b/notification/notifications.go @@ -109,7 +109,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) { 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 wSession.EventQueue.AddHandler(event.HandleFunc(event2Notification)) diff --git a/output/outputs.go b/output/outputs.go index 1def94e..0707f2b 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -69,7 +69,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) { 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. @@ -362,7 +362,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { defer util.Recover() 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 buf, _ := ioutil.ReadAll(reader) @@ -454,7 +454,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { } 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] err := wsChannel.WriteJSON(&channelRet) diff --git a/session/sessions.go b/session/sessions.go index 9176d51..5c92aea 100644 --- a/session/sessions.go +++ b/session/sessions.go @@ -177,7 +177,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) { 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) @@ -191,14 +191,13 @@ func WSHandler(w http.ResponseWriter, r *http.Request) { 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{}{} for { if err := wsChan.ReadJSON(&input); err != nil { - logger.Debugf("[Session Channel] of session [%s] disconnected, releases all resources with it, user [%s]", - sid, wSession.Username) + logger.Tracef("[Session Channel] of session [%s] disconnected, releases all resources with it, user [%s]", sid, wSession.Username) WideSessions.Remove(sid) diff --git a/shell/shells.go b/shell/shells.go index a0a6a98..96969d9 100644 --- a/shell/shells.go +++ b/shell/shells.go @@ -70,7 +70,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { 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") diff --git a/views/index.html b/views/index.html index 1960960..4bc996e 100644 --- a/views/index.html +++ b/views/index.html @@ -347,7 +347,7 @@
  diff --git a/views/preference.html b/views/preference.html index 120cc45..b6482f5 100644 --- a/views/preference.html +++ b/views/preference.html @@ -91,7 +91,7 @@