Update CCLogger

This commit is contained in:
Thomas Roehl 2022-01-26 17:09:20 +01:00
parent 5600cf1f5f
commit 0a383a3789

View File

@ -2,12 +2,11 @@ package cclogger
import (
"fmt"
"runtime"
"os"
"log"
"os"
"runtime"
)
var (
globalDebug = false
stdout = os.Stdout
@ -37,34 +36,34 @@ func initLogger() {
}
}
func Print(e ... interface{}) {
func Print(e ...interface{}) {
initLogger()
defaultLog.Print(e)
}
func ComponentPrint(component string, e ... interface{}) {
func ComponentPrint(component string, e ...interface{}) {
initLogger()
defaultLog.Print(fmt.Sprintf("[%s] ", component), e)
}
func Info(e ... interface{}) {
func Info(e ...interface{}) {
initLogger()
infoLog.Print(e)
}
func ComponentInfo(component string, e ... interface{}) {
func ComponentInfo(component string, e ...interface{}) {
initLogger()
infoLog.Print(fmt.Sprintf("[%s] ", component), e)
}
func Debug(e ... interface{}) {
func Debug(e ...interface{}) {
initLogger()
if globalDebug == true {
debugLog.Print(e)
}
}
func ComponentDebug(component string, e ... interface{}) {
func ComponentDebug(component string, e ...interface{}) {
initLogger()
if globalDebug == true && debugLog != nil {
//CCComponentPrint(debugLog, component, e)
@ -72,13 +71,13 @@ func ComponentDebug(component string, e ... interface{}) {
}
}
func Error(e ... interface{}) {
func Error(e ...interface{}) {
initLogger()
_, fn, line, _ := runtime.Caller(1)
errorLog.Print(fmt.Sprintf("[%s:%d] ", fn, line), e)
}
func ComponentError(component string, e ... interface{}) {
func ComponentError(component string, e ...interface{}) {
initLogger()
_, fn, line, _ := runtime.Caller(1)
errorLog.Print(fmt.Sprintf("[%s|%s:%d] ", component, fn, line), e)
@ -89,7 +88,6 @@ func SetDebug() {
initLogger()
}
func SetOutput(filename string) {
if filename == "stderr" {
if stderr != os.Stderr && stderr != os.Stdout {