Why can't I output logs to the VsCode console

it doesn’t output any log when i use json.encode in my project ;

VSCode Launch Config

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Corona-Run",
            "type": "lua-local",
            "request": "launch",
            "program": {
                "command": "%CORONA_PATH%/Corona Simulator.exe"
            },
            "args": [
                "-no-console",
                "main.lua"
            ]
        }
    ]
}

main.lua

json = require("json")

print("====== before encode")
local sRet = json.encode({a = 1})
print("====== encode result:", sRet)
print("====== after encode")

local iCount = 1
timer.performWithDelay(1000, function()
    print(iCount)
    iCount = iCount + 1
end, -1)

Try putting this at the top of main.lua

io.output():setvbuf("no") 

Probably won’t help, but just in case.

You’re saying you get no messages at all? Not even the start up copyright statement?

I found a strange problem when I output a string containing “{”, the output does not show. And any subsequent output is not shown. But when I closed the program, the hidden logs all showed up.

main.lua

io.output():setvbuf("no") 

print("== before")
print("{")
print("== before")

it just print == before

when i close the program,all the log are show…

can you help me

I was curious, do you only use VScode to develop on Solar2D? what extensions do you use?

Are you using Solar2d-companion?

@yu66433 - I don’t have any more ideas on this.

i use Local Lua Debugger to launch corona

Name: Local Lua Debugger
Id: tomblind.local-lua-debugger-vscode
Description: Local Lua Debugger - simple Lua debugger with no dependencies
Version: 0.2.0
Publisher: Tom Blind
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode

1 Like

I haven’t used it yet, but my colleagues are using it. Thank you for your plugin.