From e15cfb66d1a7beb579563bf76589bec57972597d Mon Sep 17 00:00:00 2001 From: tidwall Date: Sat, 27 Oct 2018 07:08:24 -0700 Subject: [PATCH] Inline optimization --- internal/log/log.go | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/internal/log/log.go b/internal/log/log.go index b5e28f34..6f1a7e29 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -61,52 +61,72 @@ var emptyFormat string // Infof ... func Infof(format string, args ...interface{}) { - log(1, "INFO", "\x1b[36m", true, format, args...) + if Level >= 1 { + log(1, "INFO", "\x1b[36m", true, format, args...) + } } // Info ... func Info(args ...interface{}) { - log(1, "INFO", "\x1b[36m", false, emptyFormat, args...) + if Level >= 1 { + log(1, "INFO", "\x1b[36m", false, emptyFormat, args...) + } } // HTTPf ... func HTTPf(format string, args ...interface{}) { - log(1, "HTTP", "\x1b[1m\x1b[30m", true, format, args...) + if Level >= 1 { + log(1, "HTTP", "\x1b[1m\x1b[30m", true, format, args...) + } } // HTTP ... func HTTP(args ...interface{}) { - log(1, "HTTP", "\x1b[1m\x1b[30m", false, emptyFormat, args...) + if Level >= 1 { + log(1, "HTTP", "\x1b[1m\x1b[30m", false, emptyFormat, args...) + } } // Errorf ... func Errorf(format string, args ...interface{}) { - log(1, "ERRO", "\x1b[1m\x1b[31m", true, format, args...) + if Level >= 1 { + log(1, "ERRO", "\x1b[1m\x1b[31m", true, format, args...) + } } // Error .. func Error(args ...interface{}) { - log(1, "ERRO", "\x1b[1m\x1b[31m", false, emptyFormat, args...) + if Level >= 1 { + log(1, "ERRO", "\x1b[1m\x1b[31m", false, emptyFormat, args...) + } } // Warnf ... func Warnf(format string, args ...interface{}) { - log(2, "WARN", "\x1b[33m", true, format, args...) + if Level >= 2 { + log(2, "WARN", "\x1b[33m", true, format, args...) + } } // Warn ... func Warn(args ...interface{}) { - log(2, "WARN", "\x1b[33m", false, emptyFormat, args...) + if Level >= 2 { + log(2, "WARN", "\x1b[33m", false, emptyFormat, args...) + } } // Debugf ... func Debugf(format string, args ...interface{}) { - log(3, "DEBU", "\x1b[35m", true, format, args...) + if Level >= 3 { + log(3, "DEBU", "\x1b[35m", true, format, args...) + } } // Debug ... func Debug(args ...interface{}) { - log(3, "DEBU", "\x1b[35m", false, emptyFormat, args...) + if Level >= 3 { + log(3, "DEBU", "\x1b[35m", false, emptyFormat, args...) + } } // Printf ...