From 1c93903203809e8a5554940b950d2ae58e3a256d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 15 Jun 2019 19:14:09 -0700 Subject: [PATCH] make a custom log Signed-off-by: Jeff Carr --- Makefile | 16 ++++++++++++++ log.go | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 Makefile create mode 100644 log.go diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4016346 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +all: + # 'gaper' is a simple and smart golang tool that just rebuilds every time you change a file + # go get -u github.com/maxcnunes/gaper + # gaper + +# simple sortcut to push all git changes +push: + # git pull + git add --all + -git commit -a -s + git push + +# should update every go dependancy (?) +update: + git pull + go get -v -t -u ./... diff --git a/log.go b/log.go new file mode 100644 index 0000000..850ae06 --- /dev/null +++ b/log.go @@ -0,0 +1,63 @@ +package log + +/* + send it anything, always get back a string +*/ + +import "fmt" +import origlog "log" +import "github.com/sirupsen/logrus" +import "git.wit.com/wit/shell" + +var debug bool = false +var warn bool = false +var err bool = false + +func SetDebug(a bool) { + debug = a +} + +func SetWarn(a bool) { + warn = a +} + +func SetError(a bool) { + err = a +} + +func Print(a ...interface{}) { + origlog.Println(a) +} + +func Println(format string, a ...interface{}) { + if (debug) { + logrus.Println(a) + } + var tmp string + if (a == nil) { + tmp = fmt.Sprintf(format) + } else { + tmp = fmt.Sprintf(format, a) + } + origlog.Println(shell.Chomp(tmp)) +} + +func Debug(a ...interface{}) { + if (debug) { + origlog.Println(a) + } +} + +func Debugln(a ...interface{}) { + if (debug) { + origlog.Println(a) + } +} + +func Warn(a ...interface{}) { + origlog.Println(a) +} + +func Error(a ...interface{}) { + origlog.Println(a) +}