From 9595dca64883b7c96e9a92d1aacf137ca74a5b99 Mon Sep 17 00:00:00 2001 From: ElvinChan Date: Wed, 22 Jun 2016 10:10:01 +0800 Subject: [PATCH] Add condition for not escape formatted log --- runner/logger.go | 8 ++++++-- runner/start.go | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/runner/logger.go b/runner/logger.go index ae2f3b1..57757cb 100644 --- a/runner/logger.go +++ b/runner/logger.go @@ -12,7 +12,7 @@ type logFunc func(string, ...interface{}) var logger = logPkg.New(colorable.NewColorableStderr(), "", 0) -func newLogFunc(prefix string) func(string, ...interface{}) { +func newLogFunc(prefix string, withEscape bool) func(string, ...interface{}) { color, clear := "", "" if settings["colors"] == "1" { color = fmt.Sprintf("\033[%sm", logColor(prefix)) @@ -24,7 +24,11 @@ func newLogFunc(prefix string) func(string, ...interface{}) { now := time.Now() timeString := fmt.Sprintf("%d:%d:%02d", now.Hour(), now.Minute(), now.Second()) format = fmt.Sprintf("%s%s %s |%s %s", color, timeString, prefix, clear, format) - logger.Printf(format, v...) + if withEscape { + logger.Printf(format, v...) + } else { + logger.Print(format) + } } } diff --git a/runner/start.go b/runner/start.go index 82b8561..c5632f0 100644 --- a/runner/start.go +++ b/runner/start.go @@ -80,11 +80,11 @@ func init() { } func initLogFuncs() { - mainLog = newLogFunc("main") - watcherLog = newLogFunc("watcher") - runnerLog = newLogFunc("runner") - buildLog = newLogFunc("build") - appLog = newLogFunc("app") + mainLog = newLogFunc("main", true) + watcherLog = newLogFunc("watcher", true) + runnerLog = newLogFunc("runner", true) + buildLog = newLogFunc("build", true) + appLog = newLogFunc("app", false) } func setEnvVars() {