Option to have PlaydateSimulator send console output to stdout

I occasionally want to collect console output from the PlaydateSimulator (or from the physical Playdate when running connected to the PlaydateSimulator). I can copy and paste out of the Console window, but it would often be easier to just redirect it into a file or have it visible in my terminal even the the simulator is blocking on my program.

As I imagine somethings this is an absolute firehose, I would understand not wanting to make this the default. But something like --console-to-stdout would be nifty.

What platform are you on? It does copy to stdout on macOS: If you launch the simulator from Terminal.app you'll see everything that prints on the console in the terminal as well. If it doesn't do that on Windows or Linux we need to fix that.

So print(...) should be emitting to stdout? It isn't on my system (SDK 1.12.3 on Ubuntu 20.04).

Running the following, I get the given output in my terminal. Nothing is emitted past "Loading: OK". (I added blank lines between commands for clarity.)

$ ls src
main.lua

$ cat src/main.lua
function playdate.update()
        print(playdate.getCurrentTimeMilliseconds())
end

$ rm -rf out.pdx

$ pdc --version
1.12.3

$ pdc src out.pdx

$ PlaydateSimulator out.pdx
14:01:41: Debug: SimulatorApp::OnInit()
14:01:41: Logging started [2022-08-18T14:01:41]
14:01:41: Logging to [/home/chaos/.Playdate Simulator/Playdate Simulator.log]
14:01:42: SDK: /opt/PlaydateSDK-1.12.3
14:01:42: Release: 1.12.3
14:01:43: cmd line pdx path: out.pdx
14:01:43: Loading: out.pdx
14:01:43: Loading: OK

Meanwhile, the Playdate Console window (View > Show Debug Console) is the firehose I expect:

14:01:42: SDK: /opt/PlaydateSDK-1.12.3
14:01:42: Release: 1.12.3
14:01:43: cmd line pdx path: out.pdx
14:01:43: Loading: out.pdx
14:01:43: Loading: OK
348
351
383
416
457
481
514
547
580
612
645

and so continuing until paused.

Information about the Simulator (as opposed to the app) is displayed, sometimes in both channels. For example, I paused my app, plugged in my Playdate, unlocked it, found myself in the Settings app, and locked it.

Output to window:

14:06:11: Device Connected: /dev/ttyACM0
14:06:11: PlaydateSerialOpen (/dev/ttyACM0)
14:06:11: SerialReadThread::Entry
echo off
~version:
target=DVT1
build=59185ded27c7-1.12.3-release.140884-buildbot-20220811_165705
boot_build=59185ded27c7-1.12.3-release.140884-buildbot
SDK=1.12.3
pdxversion=11200
serial#=PDU1-Y007110
cc=9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
time and date set
14:06:26: Device Disconnected: /dev/ttyACM0
14:06:26: PlaydateSerialClose (31)
14:06:26: SerialReadThread OnExit

while my terminal adds:

14:06:11: Device Connected: /dev/ttyACM0
14:06:11: PlaydateSerialOpen (/dev/ttyACM0)
14:06:11: SerialReadThread::Entry
14:06:26: Device Disconnected: /dev/ttyACM0
14:06:26: PlaydateSerialClose (31)
14:06:26: SerialReadThread OnExit

Okay, looks like it's not implemented correctly. I'll file that, should be an easy fix. Here's what that looks like on macOS:

dave@Dave Desktop % mkdir test
dave@Dave Desktop % echo "function playdate.update() print(playdate.getCurrentTimeMilliseconds()) end" > test/main.lua
dave@Dave Desktop % pdc test
dave@Dave Desktop % ./Playdate/SDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator test.pdx
2022-08-18 14:17:39.971 Playdate Simulator[35792:1244069] GIT_COMMIT: 7b142bf37a99_dirty-main-dev.20220805153817-dave
112
115
115
115
115
115
118
118
118
303
336
371
403
436
469
503