mirror of
https://github.com/beego/bee.git
synced 2024-12-24 23:30:48 +00:00
Update color ouput
This commit is contained in:
parent
a6840ebafd
commit
055609f64d
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
bee
|
||||
*.exe
|
||||
*.exe~
|
3
run.go
3
run.go
@ -68,7 +68,8 @@ var conf struct {
|
||||
func runApp(cmd *Command, args []string) {
|
||||
exit := make(chan bool)
|
||||
if len(args) != 1 {
|
||||
colorLog("[ERRO] Argument [appname] is missing\n")
|
||||
colorLog("[ERRO] Cannot start running[ %s ]\n",
|
||||
"argument 'appname' is missing")
|
||||
os.Exit(2)
|
||||
}
|
||||
crupath, _ := os.Getwd()
|
||||
|
14
util.go
14
util.go
@ -62,12 +62,16 @@ func colorLog(format string, a ...interface{}) {
|
||||
log = log[i+1:]
|
||||
|
||||
// Error.
|
||||
log = strings.Replace(log, "[ ", fmt.Sprintf("[ \033[%dm", Red), -1)
|
||||
log = strings.Replace(log, " ]", EndColor+" ]", -1)
|
||||
log = strings.Replace(log, "[ ", fmt.Sprintf("[\033[%dm", Red), -1)
|
||||
log = strings.Replace(log, " ]", EndColor+"]", -1)
|
||||
|
||||
// Path.
|
||||
log = strings.Replace(log, "(", fmt.Sprintf("(\033[%dm", Yellow), -1)
|
||||
log = strings.Replace(log, ")", EndColor+")", -1)
|
||||
log = strings.Replace(log, "( ", fmt.Sprintf("(\033[%dm", Yellow), -1)
|
||||
log = strings.Replace(log, " )", EndColor+")", -1)
|
||||
|
||||
// Highlights.
|
||||
log = strings.Replace(log, "# ", fmt.Sprintf("\033[%dm", Gray), -1)
|
||||
log = strings.Replace(log, " #", EndColor, -1)
|
||||
|
||||
log = clog + log
|
||||
}
|
||||
@ -79,6 +83,8 @@ func colorLog(format string, a ...interface{}) {
|
||||
func getColorLevel(level string) string {
|
||||
level = strings.ToUpper(level)
|
||||
switch level {
|
||||
case "TRAC":
|
||||
return fmt.Sprintf("\033[%dm%s\033[0m", Blue, level)
|
||||
case "ERRO":
|
||||
return fmt.Sprintf("\033[%dm%s\033[0m", Red, level)
|
||||
case "WARN":
|
||||
|
10
watch.go
10
watch.go
@ -20,7 +20,8 @@ var (
|
||||
func NewWatcher(paths []string) {
|
||||
watcher, err := fsnotify.NewWatcher()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
colorLog("[ERRO] Fail to create new Watcher[ %s ]\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
go func() {
|
||||
@ -39,7 +40,7 @@ func NewWatcher(paths []string) {
|
||||
|
||||
mt := getFileModTime(e.Name)
|
||||
if t := eventTime[e.Name]; mt == t {
|
||||
colorLog("[SKIP] %s\n", e.String())
|
||||
colorLog("[SKIP] # %s #\n", e.String())
|
||||
isbuild = false
|
||||
}
|
||||
|
||||
@ -57,10 +58,11 @@ func NewWatcher(paths []string) {
|
||||
|
||||
colorLog("[INFO] Initializing watcher...\n")
|
||||
for _, path := range paths {
|
||||
fmt.Println(path)
|
||||
colorLog("[TRAC] Directory( %s )\n", path)
|
||||
err = watcher.Watch(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
colorLog("[ERRO] Fail to watch directory[ %s ]\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user