-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
34 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,50 @@ | ||
package logger | ||
|
||
import ( | ||
"github.com/fatih/color" | ||
import "fmt" | ||
|
||
// Bash Color codes | ||
// https://stackoverflow.com/a/69648792/4480179 | ||
const ( | ||
RED string = "\033[38;5;196m" | ||
GREEN string = "\033[38;5;046m" | ||
CYAN string = "\033[38;5;014m" | ||
ORANGE string = "\033[38;5;202m" | ||
YELLOW string = "\033[38;5;011m" | ||
MAGENTA string = "\033[38;5;201m" | ||
GRAY string = "\033[38;5;245m" | ||
WHITE string = "\033[38;5;255m" | ||
RESET string = "\033[0m" | ||
) | ||
|
||
var Messagef = color.New(color.FgCyan).PrintfFunc() | ||
func Infof(format string, a ...interface{}) { | ||
fmt.Printf(WHITE+format+RESET+"\n", a...) | ||
} | ||
|
||
var Warnf = color.New(color.FgYellow).PrintfFunc() | ||
func Warnf(format string, a ...interface{}) { | ||
fmt.Printf(YELLOW+"⚠️ "+format+RESET+"\n", a...) | ||
} | ||
|
||
func Checkf(format string, a ...interface{}) { | ||
Messagef("✔ "+format+"\n", a...) | ||
fmt.Printf(GREEN+"✔ "+GRAY+format+RESET+"\n", a...) | ||
} | ||
|
||
func Hintf(format string, a ...interface{}) { | ||
Warnf("💡 "+format+"\n", a...) | ||
func Successf(format string, a ...interface{}) { | ||
fmt.Printf(GREEN+"✅ "+format+RESET+"\n", a...) | ||
} | ||
|
||
func Successf(format string, a ...interface{}) { | ||
color.New(color.FgHiGreen).PrintfFunc()("✅ "+format+"\n", a...) | ||
func Hintf(format string, a ...interface{}) { | ||
fmt.Printf(ORANGE+"💡 "+format+RESET+"\n", a...) | ||
} | ||
|
||
func Errorf(format string, a ...interface{}) { | ||
color.New(color.FgRed).PrintfFunc()("❌ "+format+"\n", a...) | ||
fmt.Printf(RED+"❌ "+format+RESET+"\n", a...) | ||
} | ||
|
||
// This variable gets its value in cmd/root.go from the CLI flag | ||
var DebugEnabled bool | ||
|
||
func Debugf(format string, a ...interface{}) { | ||
if DebugEnabled { | ||
color.New(color.FgMagenta).Printf("[DEBUG] "+format+"\n", a...) | ||
fmt.Printf(MAGENTA+"[DEBUG] "+format+RESET+"\n", a...) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters