Browse Source

Colors for the logger.

Blallo 5 years ago
parent
commit
364743f967
1 changed files with 17 additions and 1 deletions
  1. 17 1
      sizer/logger.go

+ 17 - 1
sizer/logger.go

@@ -1,6 +1,10 @@
 package sizer
 
-import "log"
+import (
+	"log"
+
+	"github.com/fatih/color"
+)
 
 // Debug is a global bool to toggle debugging messages.
 var Debug bool
@@ -59,3 +63,15 @@ var Console console
 func init() {
 	Console.SetFlags(0)
 }
+
+// Red is a function that, given a string, returns the string
+// in ANSI red foreground color.
+var Red = color.New(color.FgRed).SprintFunc()
+
+// Green is a function that, given a string, returns the string
+// in ANSI green foreground color.
+var Green = color.New(color.FgGreen).SprintFunc()
+
+// Cyan is a function that, given a string, returns the string
+// in ANSI cyan foreground color.
+var Cyan = color.New(color.FgCyan).SprintFunc()