1
0
mirror of https://github.com/beego/bee.git synced 2025-07-03 15:20:17 +00:00

Colorful log print

This commit is contained in:
Unknown
2013-08-09 22:40:46 +08:00
parent 89acd00955
commit ea43654872
4 changed files with 81 additions and 21 deletions

View File

@ -41,14 +41,14 @@ func NewWatcher(paths []string) {
// if 500ms change many times, then ignore it.
// for liteide often gofmt code after save.
if t.Add(time.Millisecond * 500).After(time.Now()) {
fmt.Println("[SKIP]", e.String())
colorLog("[SKIP] %s\n", e.String())
isbuild = false
}
}
eventTime[e.Name] = time.Now()
if isbuild {
fmt.Println("[EVEN]", e)
colorLog("[EVEN] %s\n", e)
go Autobuild()
}
case err := <-watcher.Error:
@ -57,7 +57,7 @@ func NewWatcher(paths []string) {
}
}()
fmt.Println("[INFO] Initializing watcher...")
colorLog("[INFO] Initializing watcher...\n")
for _, path := range paths {
fmt.Println(path)
err = watcher.Watch(path)
@ -72,7 +72,7 @@ func Autobuild() {
state.Lock()
defer state.Unlock()
fmt.Println("[INFO] Start building...")
colorLog("[INFO] Start building...\n")
path, _ := os.Getwd()
os.Chdir(path)
@ -94,10 +94,10 @@ func Autobuild() {
}
if err != nil {
fmt.Println("[ERRO] ============== Build failed ===================")
colorLog("[ERRO] ============== Build failed ===================\n")
return
}
fmt.Println("[SUCC] Build was successful")
colorLog("[SUCC] Build was successful\n")
Restart(appname)
}
@ -119,7 +119,7 @@ func Restart(appname string) {
}
func Start(appname string) {
fmt.Println("[INFO] Restarting", appname)
colorLog("[INFO] Restarting %s ...\n", appname)
if strings.Index(appname, "./") == -1 {
appname = "./" + appname
}