Wails V2.8.0 KnownStructs output should not be output to STD_ERROR.
Description
When I redirect error output to file on Windows, I found a lot of output from wails.
if runtime.GOOS == "windows" {
file, err := os.OpenFile("log/panic.log", os.O_CREATE|os.O_APPEND, 0666)
globalFile = file
if err != nil {
return err
}
kernel32 := syscall.NewLazyDLL("kernel32.dll")
setStdHandle := kernel32.NewProc("SetStdHandle")
sh := syscall.STD_ERROR_HANDLE
v, _, err := setStdHandle.Call(uintptr(sh), uintptr(globalFile.Fd()))
if v == 0 {
return err
}
}
I checked the wails source code and found output here is println:
But println wtrites the result to standard error
To Reproduce
file internal\typescriptify\typescriptify.go line 659, 660
...
if field.Type.Name() != "" {
typeScriptChunk, err := t.convertType(depth+1, field.Type, customCode)
if err != nil {
return "", err
}
if typeScriptChunk != "" {
result = typeScriptChunk + "\n" + result
}
}
isKnownType := t.KnownStructs.Contains(getStructFQN(field.Type.String()))
-> println("KnownStructs:", t.KnownStructs.Join("\t"))
-> println(getStructFQN(field.Type.String()))
builder.AddStructField(jsonFieldName, field, !isKnownType)
} else if field.Type.Kind() == reflect.Map {
t.logf(depth, "- map field %s.%s", typeOf.Name(), field.Name)
// Also convert map key types if needed
var keyTypeToConvert reflect.Type
switch field.Type.Key().Kind() {
case reflect.Struct:
keyTypeToConvert = field.Type.Key()
case reflect.Ptr:
keyTypeToConvert = field.Type.Key().Elem()
}
...
Expected behaviour
Write to standard output
Screenshots
No response
Attempted Fixes
This shuould be write to std output. such as fmt.println
System Details
# Wails
Version | v2.8.0
Additional context
No response
Thanks for using Wails and reporting this.
I'm not sure we are going to change this for v2 anymore, because in v3 we use static analysis to generate the bindings.
Nevertheless you can use the build tag bindings to detect if the app is being built for binding generation or not. So if the bindings tag is used, you can conditionally skip the setup of the panic.log error handler and you should be fine.