Skip to content

Commit

Permalink
Restore logs
Browse files Browse the repository at this point in the history
  • Loading branch information
clementblaise committed Feb 8, 2021
1 parent 2728176 commit 2d771c8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/utils/logs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package utils

import (
"fmt"
"os"
"strings"
)

func isTerminal() bool {
fileInfo, _ := os.Stdout.Stat()
return (fileInfo.Mode() & os.ModeCharDevice) != 0
}

func WrapYellow(msg ...string) string {
return wrapLog("33", msg...)
}

func WrapGrey(msg ...string) string {
return wrapLog("37", msg...)
}

func WrapRed(msg ...string) string {
return wrapLog("91", msg...)
}

func wrapLog(color string, msg ...string) string {
if isTerminal() {
return fmt.Sprint("\033[1;", color, "m", strings.Join(msg, EmptyString), "\033[0m")
} else {
return fmt.Sprint(strings.Join(msg, EmptyString))
}
}

0 comments on commit 2d771c8

Please sign in to comment.