mirror of
https://github.com/minio/minio.git
synced 2025-12-01 22:02:33 -05:00
Refactoring pkg/utils/log, copying from golang's log and modifying
This commit is contained in:
@@ -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...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user