From ccd6975f5fd31f2a6aa53755cc44d753bb9fc114 Mon Sep 17 00:00:00 2001 From: tidwall Date: Mon, 22 Oct 2018 14:52:48 -0700 Subject: [PATCH] Fix some tests --- internal/clip/clip_test.go | 4 ++-- internal/log/log.go | 43 +++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/internal/clip/clip_test.go b/internal/clip/clip_test.go index dbe562b1..a0bba35e 100644 --- a/internal/clip/clip_test.go +++ b/internal/clip/clip_test.go @@ -8,7 +8,7 @@ import ( ) func LO(points []geometry.Point) *geojson.LineString { - return geojson.NewLineString(geometry.NewLine(points, geometry.DefaultIndex)) + return geojson.NewLineString(geometry.NewLine(points, nil)) } func RO(minX, minY, maxX, maxY float64) *geojson.Rect { @@ -19,7 +19,7 @@ func RO(minX, minY, maxX, maxY float64) *geojson.Rect { } func PPO(exterior []geometry.Point, holes [][]geometry.Point) *geojson.Polygon { - return geojson.NewPolygon(geometry.NewPoly(exterior, holes, geometry.DefaultIndex)) + return geojson.NewPolygon(geometry.NewPoly(exterior, holes, nil)) } func TestClipLineStringSimple(t *testing.T) { diff --git a/internal/log/log.go b/internal/log/log.go index 9a2a1fd3..b5e28f34 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -19,7 +19,7 @@ var tty bool // 1: normal - show everything except debug and warn // 2: verbose - show everything except debug // 3: very verbose - show everything -var Level int = 1 +var Level = 1 // SetOutput sets the output of the logger func SetOutput(w io.Writer) { @@ -57,47 +57,76 @@ func log(level int, tag, color string, formatted bool, format string, args ...in mu.Unlock() } +var emptyFormat string + +// Infof ... func Infof(format string, args ...interface{}) { log(1, "INFO", "\x1b[36m", true, format, args...) } + +// Info ... func Info(args ...interface{}) { - log(1, "INFO", "\x1b[36m", false, "", args...) + 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...) } + +// HTTP ... func HTTP(args ...interface{}) { - log(1, "HTTP", "\x1b[1m\x1b[30m", false, "", args...) + 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...) } + +// Error .. func Error(args ...interface{}) { - log(1, "ERRO", "\x1b[1m\x1b[31m", false, "", args...) + 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...) } + +// Warn ... func Warn(args ...interface{}) { - log(2, "WARN", "\x1b[33m", false, "", args...) + log(2, "WARN", "\x1b[33m", false, emptyFormat, args...) } + +// Debugf ... func Debugf(format string, args ...interface{}) { log(3, "DEBU", "\x1b[35m", true, format, args...) } + +// Debug ... func Debug(args ...interface{}) { - log(3, "DEBU", "\x1b[35m", false, "", args...) + log(3, "DEBU", "\x1b[35m", false, emptyFormat, args...) } + +// Printf ... func Printf(format string, args ...interface{}) { Infof(format, args...) } + +// Print ... func Print(format string, args ...interface{}) { Info(args...) } + +// Fatalf ... func Fatalf(format string, args ...interface{}) { log(1, "FATA", "x1b[31m", true, format, args...) os.Exit(1) } + +// Fatal ... func Fatal(args ...interface{}) { - log(1, "FATA", "\x1b[31m", false, "", args...) + log(1, "FATA", "\x1b[31m", false, emptyFormat, args...) os.Exit(1) }