This commit is contained in:
parent
a8c5bd20a2
commit
abfd4ad782
|
@ -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")
|
||||
|
|
|
@ -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)}
|
||||
|
|
20
log/logs.go
20
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
|
||||
|
|
2
main.go
2
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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@
|
|||
|
||||
<div class="fn-right">
|
||||
<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"
|
||||
title="{{.user.Name}}"/>
|
||||
<span class="font-ico ico-share"></span>
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
<input data-value="{{.user.Password}}" value="{{.user.Password}}" name="password" type="password"/>
|
||||
</label>
|
||||
<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"
|
||||
title="{{.user.Name}}" class='gravatar'/>
|
||||
<a href="http://gravatar.com/" target="_blank">{{.i18n.change_avatar}} Gravatar.com</a>
|
||||
|
|
Loading…
Reference in New Issue