-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
collect errors and improve logging (#3)
- Loading branch information
1 parent
634f7a7
commit ed4fa88
Showing
11 changed files
with
170 additions
and
93 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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/fatih/color" | ||
) | ||
|
||
var verbose = false | ||
|
||
func SetLogVerbosity(value bool) { | ||
verbose = value | ||
} | ||
|
||
var debugC = color.New(color.FgBlue).SprintFunc()("debug") | ||
var infoC = color.New(color.FgGreen).SprintFunc()("info ") | ||
var warningC = color.New(color.FgYellow).SprintFunc()("warn ") | ||
var errorC = color.New(color.FgRed).SprintFunc()("error") | ||
|
||
func LogDebug(msg string, args ...interface{}) { | ||
if verbose { | ||
fmt.Printf("[%s] %s\n", debugC, fmt.Sprintf(msg, args...)) | ||
} | ||
} | ||
|
||
func LogInfo(msg string, args ...interface{}) { | ||
fmt.Printf("[%s] %s\n", infoC, fmt.Sprintf(msg, args...)) | ||
} | ||
|
||
func LogWarning(msg string, args ...interface{}) { | ||
fmt.Printf("[%s] %s\n", warningC, fmt.Sprintf(msg, args...)) | ||
} | ||
|
||
func LogError(msg string, args ...interface{}) { | ||
fmt.Printf("[%s] %s\n", errorC, fmt.Sprintf(msg, args...)) | ||
} |
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
Oops, something went wrong.