日志级别
This commit is contained in:
parent
98742b2ce2
commit
c868d2650a
13
conf/wide.go
13
conf/wide.go
|
@ -3,14 +3,15 @@ package conf
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
_ "github.com/b3log/wide/i18n"
|
||||
"github.com/b3log/wide/util"
|
||||
"github.com/golang/glog"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
_ "github.com/b3log/wide/i18n"
|
||||
"github.com/b3log/wide/util"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
|
@ -87,7 +88,7 @@ func Load() {
|
|||
os.Exit(-1)
|
||||
}
|
||||
|
||||
glog.Infof("IP [%s]", ip)
|
||||
glog.V(3).Infof("IP [%s]", ip)
|
||||
Wide.Server = strings.Replace(Wide.Server, "{IP}", ip, 1)
|
||||
Wide.StaticServer = strings.Replace(Wide.StaticServer, "{IP}", ip, 1)
|
||||
Wide.EditorChannel = strings.Replace(Wide.EditorChannel, "{IP}", ip, 1)
|
||||
|
@ -98,10 +99,10 @@ func Load() {
|
|||
file, _ := exec.LookPath(os.Args[0])
|
||||
pwd, _ := filepath.Abs(file)
|
||||
pwd = pwd[:strings.LastIndex(pwd, string(os.PathSeparator))]
|
||||
glog.Infof("pwd [%s]", pwd)
|
||||
glog.V(3).Infof("pwd [%s]", pwd)
|
||||
|
||||
Wide.Workspace = strings.Replace(Wide.Workspace, "{pwd}", pwd, 1)
|
||||
Wide.UserWorkspaces = strings.Replace(Wide.UserWorkspaces, "{pwd}", pwd, 1)
|
||||
|
||||
glog.Info("Conf: \n" + string(bytes))
|
||||
glog.V(3).Info("Conf: \n" + string(bytes))
|
||||
}
|
||||
|
|
|
@ -2,10 +2,11 @@ package i18n
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/golang/glog"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
type locale struct {
|
||||
|
@ -33,7 +34,7 @@ func Load() {
|
|||
}
|
||||
|
||||
Locales["zh_CN"] = zhCN
|
||||
glog.Info("Loaded [zh_CN] locale configuration")
|
||||
glog.V(5).Info("Loaded [zh_CN] locale configuration")
|
||||
}
|
||||
|
||||
func GetLangs(r *http.Request) map[string]interface{} {
|
||||
|
|
3
main.go
3
main.go
|
@ -21,6 +21,7 @@ import (
|
|||
// Wide 中唯一一个 init 函数.
|
||||
func init() {
|
||||
flag.Set("logtostderr", "true")
|
||||
flag.Set("v", "1")
|
||||
|
||||
flag.Parse()
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ func main() {
|
|||
// 文档
|
||||
http.Handle("/doc/", http.StripPrefix("/doc/", http.FileServer(http.Dir("doc"))))
|
||||
|
||||
glog.Infof("Wide is running [%s]", conf.Wide.Server)
|
||||
glog.V(0).Infof("Wide is running [%s]", conf.Wide.Server)
|
||||
|
||||
err := http.ListenAndServe(conf.Wide.Server, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -2,11 +2,6 @@ package output
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/user"
|
||||
"github.com/b3log/wide/util"
|
||||
"github.com/golang/glog"
|
||||
"github.com/gorilla/websocket"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
@ -14,6 +9,12 @@ import (
|
|||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/user"
|
||||
"github.com/b3log/wide/util"
|
||||
"github.com/golang/glog"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
var outputWS = map[string]*websocket.Conn{}
|
||||
|
@ -27,7 +28,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
|
|||
ret := map[string]interface{}{"output": "Ouput initialized", "cmd": "init-output"}
|
||||
outputWS[sid].WriteJSON(&ret)
|
||||
|
||||
glog.Infof("Open a new [Output] with session [%s], %d", sid, len(outputWS))
|
||||
glog.V(4).Infof("Open a new [Output] with session [%s], %d", sid, len(outputWS))
|
||||
}
|
||||
|
||||
func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -77,14 +78,14 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
channelRet := map[string]interface{}{}
|
||||
|
||||
go func(runningId int) {
|
||||
glog.Infof("Session [%s] is running [id=%d, file=%s]", sid, runningId, filePath)
|
||||
glog.V(3).Infof("Session [%s] is running [id=%d, file=%s]", sid, runningId, filePath)
|
||||
|
||||
for {
|
||||
buf := make([]byte, 1024)
|
||||
count, err := reader.Read(buf)
|
||||
|
||||
if nil != err || 0 == count {
|
||||
glog.Infof("Session [%s] 's running [id=%d, file=%s] has done", sid, runningId, filePath)
|
||||
glog.V(3).Infof("Session [%s] 's running [id=%d, file=%s] has done", sid, runningId, filePath)
|
||||
|
||||
break
|
||||
} else {
|
||||
|
@ -157,7 +158,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
setCmdEnv(cmd, username)
|
||||
|
||||
glog.Infof("go build -o %s %s", executable, filePath)
|
||||
glog.V(5).Infof("go build -o %s %s", executable, filePath)
|
||||
|
||||
executable = curDir + string(os.PathSeparator) + executable
|
||||
|
||||
|
@ -192,7 +193,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
cmd.Start()
|
||||
|
||||
go func(runningId int) {
|
||||
glog.Infof("Session [%s] is building [id=%d, file=%s]", sid, runningId, filePath)
|
||||
glog.V(3).Infof("Session [%s] is building [id=%d, file=%s]", sid, runningId, filePath)
|
||||
|
||||
// 一次性读取
|
||||
buf := make([]byte, 1024*8)
|
||||
|
@ -220,7 +221,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
|||
channelRet["executable"] = executable
|
||||
|
||||
if nil != outputWS[sid] {
|
||||
glog.Infof("Session [%s] 's build [id=%d, file=%s] has done", sid, runningId, filePath)
|
||||
glog.V(3).Infof("Session [%s] 's build [id=%d, file=%s] has done", sid, runningId, filePath)
|
||||
|
||||
err := outputWS[sid].WriteJSON(&channelRet)
|
||||
if nil != err {
|
||||
|
@ -282,14 +283,14 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
channelRet := map[string]interface{}{}
|
||||
|
||||
go func(runningId int) {
|
||||
glog.Infof("Session [%s] is running [go get] [runningId=%d]", sid, runningId)
|
||||
glog.V(3).Infof("Session [%s] is running [go get] [runningId=%d]", sid, runningId)
|
||||
|
||||
for {
|
||||
buf := make([]byte, 1024)
|
||||
count, err := reader.Read(buf)
|
||||
|
||||
if nil != err || 0 == count {
|
||||
glog.Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId)
|
||||
glog.V(3).Infof("Session [%s] 's running [go get] [runningId=%d] has done", sid, runningId)
|
||||
|
||||
break
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue