Refactoring pkg/utils/log, copying from golang's log and modifying

This commit is contained in:
Frederick F. Kautz IV
2015-03-28 15:58:48 -07:00
parent 7f753a3965
commit b165efdfcb
11 changed files with 336 additions and 160 deletions

View File

@@ -1,44 +0,0 @@
package log
import (
internalLog "log"
"sync"
)
// Global variable to be set
var verbosity = NormalLOG
var mutex sync.RWMutex
func verify(level Level) bool {
mutex.RLock()
defer mutex.RUnlock()
return Level(verbosity) >= level
}
// SetVerbosity - set log level value globally
func SetVerbosity(level Level) {
mutex.Lock()
defer mutex.Unlock()
verbosity = level
}
// Log - variable logging against global verbosity
func Log(level Level, args ...interface{}) {
if verify(level) {
internalLog.Print(args...)
}
}
// Logf - variable formatted logging against global verbosity
func Logf(level Level, s string, args ...interface{}) {
if verify(level) {
internalLog.Printf(s, args...)
}
}
// Logln - variable logging with newline against global verbosity
func Logln(level Level, args ...interface{}) {
if verify(level) {
internalLog.Println(args...)
}
}