Second commit - system builds

master
Sean Murphy 6 years ago
parent 40672ae730
commit 699885b61b
  1. 23
      logging.go

@ -8,6 +8,7 @@ import (
"strings"
)
// higher log level means more logging...
const (
ERROR = iota
WARNING
@ -53,10 +54,11 @@ var (
func (l *logStream) Printf(format string, a ...interface{}) {
// describe(a)
if LogLevel > l.logLevel {
if LogLevel >= l.logLevel {
return
}
// if no specific logger is configured for this logstrea, write to stdout...
if l.s == nil {
fmt.Printf(format, a...)
return
@ -74,7 +76,6 @@ func (l *logStream) init(m io.Writer, s string, ll int) {
// is no match of the string, it will return 0 which maps to error only
// logging...perhaps this could be made more explicit
func determineLogLevel(lstr string) int {
lstrLowerCase := strings.ToLower(lstr)
return logLevelStringMap[lstrLowerCase]
}
@ -98,27 +99,9 @@ func initLogger(logFile string, logLevelStr string, logToConsole bool) {
}
}
// Trace = log.New(multi, " TRACE: ", log.Ldate|log.Ltime|log.Lshortfile)
// Debug = log.New(multi, " DEBUG: ", log.Ldate|log.Ltime|log.Lshortfile)
// Info = log.New(multi, " INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
// Warning = log.New(multi, "WARNING: ", log.Ldate|log.Ltime|log.Lshortfile)
// Error = log.New(multi, " ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
// Trace = logStream{}
Trace.init(multi, " TRACE: ", TRACE)
Debug.init(multi, " DEBUG: ", DEBUG)
Info.init(multi, " INFO: ", INFO)
Warning.init(multi, "WARNING: ", WARNING)
Error.init(multi, " ERROR: ", ERROR)
}
// Printf prints output to the logger if the DefaultLogger is non nil
// - otherwise it does nothing
func Printf(format string, a ...interface{}) {
// describe(a)
if DefaultLogger == nil {
fmt.Printf(format, a...)
return
}
DefaultLogger.Printf(format, a...)
}

Loading…
Cancel
Save