From 67b7cdfc1fad22f6d631013b765f63cb24b26107 Mon Sep 17 00:00:00 2001 From: Karl Hesselgren Date: Tue, 20 Sep 2022 21:31:08 +0200 Subject: [PATCH 1/2] Fix bitmasking for logging --- raylib/raylib.go | 4 ++-- raylib/utils.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/raylib/raylib.go b/raylib/raylib.go index 65d43b3..7e8208b 100644 --- a/raylib/raylib.go +++ b/raylib/raylib.go @@ -1191,7 +1191,7 @@ func newRenderTexture2DFromPointer(ptr unsafe.Pointer) RenderTexture2D { // Log message types const ( - LogAll = iota + LogAll = 1 << iota LogTrace LogDebug LogInfo @@ -1201,4 +1201,4 @@ const ( LogNone ) -var logTypeFlags = LogInfo | LogWarning | LogError +var logTypeFlags byte = LogInfo | LogWarning | LogError diff --git a/raylib/utils.go b/raylib/utils.go index 5ed80b6..39b1373 100644 --- a/raylib/utils.go +++ b/raylib/utils.go @@ -14,7 +14,7 @@ import ( ) // SetTraceLog - Enable trace log message types -func SetTraceLog(typeFlags int) { +func SetTraceLog(typeFlags byte) { logTypeFlags = typeFlags ctypeFlags := (C.int)(typeFlags) @@ -25,19 +25,19 @@ func SetTraceLog(typeFlags int) { func TraceLog(msgType int, text string, v ...interface{}) { switch msgType { case LogInfo: - if logTypeFlags&LogInfo == 0 { + if logTypeFlags&LogInfo != 0 { fmt.Printf("INFO: "+text+"\n", v...) } case LogWarning: - if logTypeFlags&LogWarning == 0 { + if logTypeFlags&LogWarning != 0 { fmt.Printf("WARNING: "+text+"\n", v...) } case LogError: - if logTypeFlags&LogError == 0 { + if logTypeFlags&LogError != 0 { fmt.Printf("ERROR: "+text+"\n", v...) } case LogDebug: - if logTypeFlags&LogDebug == 0 { + if logTypeFlags&LogDebug != 0 { fmt.Printf("DEBUG: "+text+"\n", v...) } } From 69fb70441e484d600e98fddc16b1d0952c3f0a57 Mon Sep 17 00:00:00 2001 From: Karl Hesselgren Date: Thu, 22 Sep 2022 10:12:34 +0200 Subject: [PATCH 2/2] Fix bitmasking for logging in windows and android implementations --- raylib/utils_android.go | 10 +++++----- raylib/utils_windows.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/raylib/utils_android.go b/raylib/utils_android.go index e7b4c5c..aa965f4 100644 --- a/raylib/utils_android.go +++ b/raylib/utils_android.go @@ -22,7 +22,7 @@ import ( ) // SetTraceLog - Enable trace log message types (bit flags based) -func SetTraceLog(typeFlags int) { +func SetTraceLog(typeFlags byte) { logTypeFlags = typeFlags ctypeFlags := (C.int)(typeFlags) @@ -33,25 +33,25 @@ func SetTraceLog(typeFlags int) { func TraceLog(msgType int, text string, v ...interface{}) { switch msgType { case LogInfo: - if logTypeFlags&LogInfo == 0 { + if logTypeFlags&LogInfo != 0 { msg := C.CString(fmt.Sprintf("INFO: "+text, v...)) defer C.free(unsafe.Pointer(msg)) C.log_info(msg) } case LogWarning: - if logTypeFlags&LogWarning == 0 { + if logTypeFlags&LogWarning != 0 { msg := C.CString(fmt.Sprintf("WARNING: "+text, v...)) defer C.free(unsafe.Pointer(msg)) C.log_warn(msg) } case LogError: - if logTypeFlags&LogError == 0 { + if logTypeFlags&LogError != 0 { msg := C.CString(fmt.Sprintf("ERROR: "+text, v...)) defer C.free(unsafe.Pointer(msg)) C.log_error(msg) } case LogDebug: - if logTypeFlags&LogDebug == 0 { + if logTypeFlags&LogDebug != 0 { msg := C.CString(fmt.Sprintf("DEBUG: "+text, v...)) defer C.free(unsafe.Pointer(msg)) C.log_debug(msg) diff --git a/raylib/utils_windows.go b/raylib/utils_windows.go index f65f140..60ee359 100644 --- a/raylib/utils_windows.go +++ b/raylib/utils_windows.go @@ -14,7 +14,7 @@ import ( ) // SetTraceLog - Enable trace log message types (bit flags based) -func SetTraceLog(typeFlags int) { +func SetTraceLog(typeFlags byte) { logTypeFlags = typeFlags ctypeFlags := (C.int)(typeFlags) @@ -25,19 +25,19 @@ func SetTraceLog(typeFlags int) { func TraceLog(msgType int, text string, v ...interface{}) { switch msgType { case LogInfo: - if logTypeFlags&LogInfo == 0 { + if logTypeFlags&LogInfo != 0 { fmt.Printf("INFO: "+text+"\n", v...) } case LogWarning: - if logTypeFlags&LogWarning == 0 { + if logTypeFlags&LogWarning != 0 { fmt.Printf("WARNING: "+text+"\n", v...) } case LogError: - if logTypeFlags&LogError == 0 { + if logTypeFlags&LogError != 0 { fmt.Printf("ERROR: "+text+"\n", v...) } case LogDebug: - if logTypeFlags&LogDebug == 0 { + if logTypeFlags&LogDebug != 0 { fmt.Printf("DEBUG: "+text+"\n", v...) } }