make a custom log

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-15 19:14:09 -07:00
commit 1c93903203
2 changed files with 79 additions and 0 deletions

16
Makefile Normal file
View File

@ -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 ./...

63
log.go Normal file
View File

@ -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)
}