Browse Source

Platform detection, disable colored console for windows

Vova Tkach 6 years ago
parent
commit
a79ae986ce
3 changed files with 20 additions and 2 deletions
  1. 5 0
      consts/platform_other.go
  2. 5 0
      consts/platform_windows.go
  3. 10 2
      logger/logger.go

+ 5 - 0
consts/platform_other.go

@@ -0,0 +1,5 @@
+// +build !windows
+
+package consts
+
+const IS_WIN = false

+ 5 - 0
consts/platform_windows.go

@@ -0,0 +1,5 @@
+// +build windows
+
+package consts
+
+const IS_WIN = true

+ 10 - 2
logger/logger.go

@@ -25,9 +25,17 @@ type Logger struct {
 func (this *Logger) console(msg logMsg) {
 func (this *Logger) console(msg logMsg) {
 	if consts.ParamDebug {
 	if consts.ParamDebug {
 		if !msg.isError {
 		if !msg.isError {
-			fmt.Fprintln(os.Stdout, "\033[0;32m[ACCESS] "+msg.message+"\033[0m")
+			if consts.IS_WIN {
+				fmt.Fprintln(os.Stdout, "[ACCESS] "+msg.message)
+			} else {
+				fmt.Fprintln(os.Stdout, "\033[0;32m[ACCESS] "+msg.message+"\033[0m")
+			}
 		} else {
 		} else {
-			fmt.Fprintln(os.Stdout, "\033[0;31m[ERROR] "+msg.message+"\033[0m")
+			if consts.IS_WIN {
+				fmt.Fprintln(os.Stdout, "[ERROR] "+msg.message)
+			} else {
+				fmt.Fprintln(os.Stdout, "\033[0;31m[ERROR] "+msg.message+"\033[0m")
+			}
 		}
 		}
 		return
 		return
 	}
 	}