Merge pull request #200 from iszla/fixLogging
Fix bitmasking for logging
This commit is contained in:
commit
a460a0fc06
4 changed files with 17 additions and 17 deletions
|
@ -1191,7 +1191,7 @@ func newRenderTexture2DFromPointer(ptr unsafe.Pointer) RenderTexture2D {
|
||||||
|
|
||||||
// Log message types
|
// Log message types
|
||||||
const (
|
const (
|
||||||
LogAll = iota
|
LogAll = 1 << iota
|
||||||
LogTrace
|
LogTrace
|
||||||
LogDebug
|
LogDebug
|
||||||
LogInfo
|
LogInfo
|
||||||
|
@ -1201,4 +1201,4 @@ const (
|
||||||
LogNone
|
LogNone
|
||||||
)
|
)
|
||||||
|
|
||||||
var logTypeFlags = LogInfo | LogWarning | LogError
|
var logTypeFlags byte = LogInfo | LogWarning | LogError
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetTraceLog - Enable trace log message types
|
// SetTraceLog - Enable trace log message types
|
||||||
func SetTraceLog(typeFlags int) {
|
func SetTraceLog(typeFlags byte) {
|
||||||
logTypeFlags = typeFlags
|
logTypeFlags = typeFlags
|
||||||
|
|
||||||
ctypeFlags := (C.int)(typeFlags)
|
ctypeFlags := (C.int)(typeFlags)
|
||||||
|
@ -25,19 +25,19 @@ func SetTraceLog(typeFlags int) {
|
||||||
func TraceLog(msgType int, text string, v ...interface{}) {
|
func TraceLog(msgType int, text string, v ...interface{}) {
|
||||||
switch msgType {
|
switch msgType {
|
||||||
case LogInfo:
|
case LogInfo:
|
||||||
if logTypeFlags&LogInfo == 0 {
|
if logTypeFlags&LogInfo != 0 {
|
||||||
fmt.Printf("INFO: "+text+"\n", v...)
|
fmt.Printf("INFO: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
case LogWarning:
|
case LogWarning:
|
||||||
if logTypeFlags&LogWarning == 0 {
|
if logTypeFlags&LogWarning != 0 {
|
||||||
fmt.Printf("WARNING: "+text+"\n", v...)
|
fmt.Printf("WARNING: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
case LogError:
|
case LogError:
|
||||||
if logTypeFlags&LogError == 0 {
|
if logTypeFlags&LogError != 0 {
|
||||||
fmt.Printf("ERROR: "+text+"\n", v...)
|
fmt.Printf("ERROR: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
case LogDebug:
|
case LogDebug:
|
||||||
if logTypeFlags&LogDebug == 0 {
|
if logTypeFlags&LogDebug != 0 {
|
||||||
fmt.Printf("DEBUG: "+text+"\n", v...)
|
fmt.Printf("DEBUG: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetTraceLog - Enable trace log message types (bit flags based)
|
// SetTraceLog - Enable trace log message types (bit flags based)
|
||||||
func SetTraceLog(typeFlags int) {
|
func SetTraceLog(typeFlags byte) {
|
||||||
logTypeFlags = typeFlags
|
logTypeFlags = typeFlags
|
||||||
|
|
||||||
ctypeFlags := (C.int)(typeFlags)
|
ctypeFlags := (C.int)(typeFlags)
|
||||||
|
@ -33,25 +33,25 @@ func SetTraceLog(typeFlags int) {
|
||||||
func TraceLog(msgType int, text string, v ...interface{}) {
|
func TraceLog(msgType int, text string, v ...interface{}) {
|
||||||
switch msgType {
|
switch msgType {
|
||||||
case LogInfo:
|
case LogInfo:
|
||||||
if logTypeFlags&LogInfo == 0 {
|
if logTypeFlags&LogInfo != 0 {
|
||||||
msg := C.CString(fmt.Sprintf("INFO: "+text, v...))
|
msg := C.CString(fmt.Sprintf("INFO: "+text, v...))
|
||||||
defer C.free(unsafe.Pointer(msg))
|
defer C.free(unsafe.Pointer(msg))
|
||||||
C.log_info(msg)
|
C.log_info(msg)
|
||||||
}
|
}
|
||||||
case LogWarning:
|
case LogWarning:
|
||||||
if logTypeFlags&LogWarning == 0 {
|
if logTypeFlags&LogWarning != 0 {
|
||||||
msg := C.CString(fmt.Sprintf("WARNING: "+text, v...))
|
msg := C.CString(fmt.Sprintf("WARNING: "+text, v...))
|
||||||
defer C.free(unsafe.Pointer(msg))
|
defer C.free(unsafe.Pointer(msg))
|
||||||
C.log_warn(msg)
|
C.log_warn(msg)
|
||||||
}
|
}
|
||||||
case LogError:
|
case LogError:
|
||||||
if logTypeFlags&LogError == 0 {
|
if logTypeFlags&LogError != 0 {
|
||||||
msg := C.CString(fmt.Sprintf("ERROR: "+text, v...))
|
msg := C.CString(fmt.Sprintf("ERROR: "+text, v...))
|
||||||
defer C.free(unsafe.Pointer(msg))
|
defer C.free(unsafe.Pointer(msg))
|
||||||
C.log_error(msg)
|
C.log_error(msg)
|
||||||
}
|
}
|
||||||
case LogDebug:
|
case LogDebug:
|
||||||
if logTypeFlags&LogDebug == 0 {
|
if logTypeFlags&LogDebug != 0 {
|
||||||
msg := C.CString(fmt.Sprintf("DEBUG: "+text, v...))
|
msg := C.CString(fmt.Sprintf("DEBUG: "+text, v...))
|
||||||
defer C.free(unsafe.Pointer(msg))
|
defer C.free(unsafe.Pointer(msg))
|
||||||
C.log_debug(msg)
|
C.log_debug(msg)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetTraceLog - Enable trace log message types (bit flags based)
|
// SetTraceLog - Enable trace log message types (bit flags based)
|
||||||
func SetTraceLog(typeFlags int) {
|
func SetTraceLog(typeFlags byte) {
|
||||||
logTypeFlags = typeFlags
|
logTypeFlags = typeFlags
|
||||||
|
|
||||||
ctypeFlags := (C.int)(typeFlags)
|
ctypeFlags := (C.int)(typeFlags)
|
||||||
|
@ -25,19 +25,19 @@ func SetTraceLog(typeFlags int) {
|
||||||
func TraceLog(msgType int, text string, v ...interface{}) {
|
func TraceLog(msgType int, text string, v ...interface{}) {
|
||||||
switch msgType {
|
switch msgType {
|
||||||
case LogInfo:
|
case LogInfo:
|
||||||
if logTypeFlags&LogInfo == 0 {
|
if logTypeFlags&LogInfo != 0 {
|
||||||
fmt.Printf("INFO: "+text+"\n", v...)
|
fmt.Printf("INFO: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
case LogWarning:
|
case LogWarning:
|
||||||
if logTypeFlags&LogWarning == 0 {
|
if logTypeFlags&LogWarning != 0 {
|
||||||
fmt.Printf("WARNING: "+text+"\n", v...)
|
fmt.Printf("WARNING: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
case LogError:
|
case LogError:
|
||||||
if logTypeFlags&LogError == 0 {
|
if logTypeFlags&LogError != 0 {
|
||||||
fmt.Printf("ERROR: "+text+"\n", v...)
|
fmt.Printf("ERROR: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
case LogDebug:
|
case LogDebug:
|
||||||
if logTypeFlags&LogDebug == 0 {
|
if logTypeFlags&LogDebug != 0 {
|
||||||
fmt.Printf("DEBUG: "+text+"\n", v...)
|
fmt.Printf("DEBUG: "+text+"\n", v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue