Browse Source

Optimization

Vova Tkach 6 years ago
parent
commit
fd71413b99
1 changed files with 4 additions and 4 deletions
  1. 4 4
      engine/sqlw/log.go

+ 4 - 4
engine/sqlw/log.go

@@ -11,10 +11,6 @@ import (
 )
 
 func log(query string, s time.Time, e error, transaction bool) {
-	color := "0;33"
-	if transaction {
-		color = "1;33"
-	}
 	msg := query
 	if reg, err := regexp.Compile("[\\s\\t]+"); err == nil {
 		msg = strings.Trim(reg.ReplaceAllString(msg, " "), " ")
@@ -29,6 +25,10 @@ func log(query string, s time.Time, e error, transaction bool) {
 	if consts.IS_WIN {
 		fmt.Fprintln(os.Stdout, "[SQL] "+msg+eStr+fmt.Sprintf(" %.3f ms", time.Now().Sub(s).Seconds()))
 	} else {
+		color := "0;33"
+		if transaction {
+			color = "1;33"
+		}
 		fmt.Fprintln(os.Stdout, "\033["+color+"m[SQL] "+msg+eStr+fmt.Sprintf(" %.3f ms", time.Now().Sub(s).Seconds())+"\033[0m")
 	}
 }